Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong numerical sort of the "Messages" column due to thousand separators #92

Open
z-image opened this issue Feb 2, 2024 · 1 comment

Comments

@z-image
Copy link

z-image commented Feb 2, 2024

Hi there,

the "Messages" column that displays numbers with thousands separators (e.g., 12,345) is not being sorted numerically as expected. Instead, it appears to be sorted as a string, where "10,000" comes before "2,000" due to the leading "1" in "10,000". This issue leads to a non-intuitive display of data where numerical values are not correctly ordered from smallest to largest (or vice versa).

Thousands separator seems useful, so maybe this should be handled in the javascript.

@z-image
Copy link
Author

z-image commented Feb 2, 2024

Works for me:

-const comparer = (idx, asc) => (a, b) => ((v1, v2) => v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2))(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx));
+const comparer = (idx, asc) => (a, b) => ((v1, v2) => v1 !== '' && v2 !== '' && !isNaN(v1 = v1.replace(/,/g, '')) && !isNaN(v2 = v2.replace(/,/g, '')) ? v1 - v2 : v1.toString().localeCompare(v2))(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant