Copy link to clipboard
Copied
Hi,
I wish to know if there is a change to sort page numbers in the table of contents but not just first digit but a number as a whole (e.g. 346 or 45). When I use Script it only sorts the numbers by the first digit so it the end I have sorted it like : 1,10,100,2,20,200,3,30,300 etc.. How can I fix it?
Copy link to clipboard
Copied
By rewriting the sortiing routine of that script - can you post the relevant part here?
Or by complying to its demands: prefix all numbers with the appropriate number of zeroes - this depends on the largest of your values.
Copy link to clipboard
Copied
Try this,
var arr = [1,10,100,2,20,200,3,30,300];
alert(arr.sort(function(a,b){return a-b}));