Skip to content

Sort with natural sort instead. #547

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

Merged
merged 1 commit into from
Jul 22, 2022
Merged

Sort with natural sort instead. #547

merged 1 commit into from
Jul 22, 2022

Conversation

n0nag0n
Copy link
Contributor

@n0nag0n n0nag0n commented Jul 22, 2022

We noticed when using the table sort that it would sort things alphabetically instead of numerically (if the field happened to start with a number). This fixes it while maintaining alphabetical sorting.

  • Improvement: Table sorting
  • BC break? no
  • doc PR: It's an internal fix that doesn't need to be documented

The problem we were running into is that we would have errors in our project sort like the following:

  • 1x
  • 1x
  • 145x
  • 2x
  • 201x
  • 3x
  • 4x
  • etc.

It is the same for measuring database query times, etc. Anything numeric with text in it, it would kinda choke. Adding these couple extra arguments to the localeCompare() function allows it to sort numerics properly while maintaining alphabetical sorting.

BTW, looked for unit tests for your js stuff, but didn't find anything 😬

We noticed when using the table sort that it would sort things alphabetically instead of numerically (if the field happened to start with a number). This fixes it while maintaining alphabetical sorting.
@dg dg merged commit 632bae9 into nette:master Jul 22, 2022
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

Successfully merging this pull request may close these issues.

2 participants