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 sorting order with grouped numbers #19

Closed
exostor opened this issue Feb 4, 2015 · 3 comments
Closed

Wrong sorting order with grouped numbers #19

exostor opened this issue Feb 4, 2015 · 3 comments
Labels

Comments

@exostor
Copy link

exostor commented Feb 4, 2015

natsort 3.5.2, python 3.2.3

>>> l=["li1-1", "li1-2", "li1-3", "li1-10", "li2-11", "li10-1", "li2-11b", "li2-11a", "li2-1b11", "li2-1b2"]
>>> natsort.natsorted(l)
['li1-10', 'li1-3', 'li1-2', 'li1-1', 'li2-11', 'li2-11a', 'li2-11b', 'li2-1b2', 'li2-1b11', 'li10-1']

But I expected the result:

['li1-1', 'li1-2', 'li1-3', 'li1-10', 'li2-1b2', 'li2-1b11', 'li2-11', 'li2-11a', 'li2-11b', 'li10-1']
@SethMMorton
Copy link
Owner

Use either versorted(l) or natsorted(l, alg=ns.UNSIGNED). Please see the 3rd example here: https://github.com/SethMMorton/natsort#quick-description.

@exostor
Copy link
Author

exostor commented Feb 5, 2015

Aha, I didn't see my case as version numbers, but yes, it works perfecly. Thanks!

@SethMMorton
Copy link
Owner

@exostor As of natsort version 4.0.0, you don't need to use versorted or ns.UNSIGNED anymore.

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

No branches or pull requests

2 participants