Skip to main content

Simple natural order sorting API for Python that just works

Project description

The natsort class in the naturalsort module is a very simple alternative to Python’s sorted() function that implements natural order sorting in Python.

Usage

Here’s an example of regular sorting vs. natural order sorting:

>>> # Import the sorted() alternative.
>>> from natsort import natsort
>>>
>>> # This is plain old sorting (what we don't want).
>>> sorted(['1', '5', '10', '50'])
['1', '10', '5', '50']
>>>
>>> # This is version sorting (what we're after).
>>> natsort(['1', '5', '10', '50'])
['1', '5', '10', '50']
>>>
>>> # This covers a previously fixed bug.
>>> natsort(['1.0', '1.5'])
['1.0', '1.5']

Contact

The latest version of naturalsort is available on PyPi and GitHub. For bug reports please create an issue on GitHub. If you have questions, suggestions, etc. feel free to send me an e-mail at peter@peterodding.com.

License

This software is licensed under the MIT license.

© 2013 Peter Odding.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for naturalsort, version 1.0
Filename, size File type Python version Upload date Hashes
Filename, size naturalsort-1.0.tar.gz (2.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page