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

Fix sorting order for numeric strings #186

Merged
merged 1 commit into from
May 3, 2024
Merged

Conversation

F4bbi
Copy link
Contributor

@F4bbi F4bbi commented Jun 26, 2023

I have noticed that since strings are compared using alphabetical order, if they start with a number they won't be compared correctly. For example, '10' will be placed before '2' in the sorted results. So, I tried to fix this problem using a regular expression that extracts the numeric portion at the beginning of each string (if it's possible) and performs a numerical comparison.
See an example below.

image

@oleeskild
Copy link
Owner

Awesome! Thank you so much!

@oleeskild oleeskild merged commit 0b9ecd7 into oleeskild:main May 3, 2024
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