• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

SortParagraph Script _ only sorts single digits but not whole numbers

New Here ,
Feb 17, 2017 Feb 17, 2017

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?

TOPICS
Scripting

Views

338

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2017 Feb 17, 2017

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 17, 2017 Feb 17, 2017

Copy link to clipboard

Copied

LATEST

Try this,

var arr = [1,10,100,2,20,200,3,30,300];

alert(arr.sort(function(a,b){return a-b}));

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines