Client-side sort using STANDARDISTA-TABLE-SORTING.js

I am using the STANDARDISTA-TABLE-SORTING.js script.

I am having a problem with the sorting of number columns. If the columns include numbers all the same length (10, 31, 15, 20, 29), it sorts correctly. If the columns include numbers of varying lengths, it does not sort correctly. Some of the data is hard-code and the other data is generated from calculations of fields from the database. The following string is an example of an incorrect sort:
Who is Participating?
I know they are just numbers ... unfortunately the script was not programmed to recognise them as numbers.
The attached version was modified by me to recognise numbers with commas as currency actually (it removes the $ and , to sort as a number).
It should be fine with other reports, unless they also had numbers with commas - then their behaviour will change too ... for the better I would imagine.  BUT I have not extensively tested it NOR can I give any guarantees.
Due to the comma in the number - it is sorting the values as text strings.

Are they $ amounts?  If so - putting a $ sign at the start (e.g. $147,194) and it will sort them properly.

If they are not $ amounts or you do not want a $ sign, then either remove the commas or a small change to the JavaScript file is required.

Which do you want?
JLohmanAuthor Commented:
They are just numbers.

If the javascript is modified, will it continue to work with other reports?

I would prefer to be able to use commas.
JLohmanAuthor Commented:
Works perfectly!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.