Skip to main content

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.

Download files

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

Source Distribution

naturalsort-1.0.tar.gz (2.9 kB view details)

Uploaded Source

File details

Details for the file naturalsort-1.0.tar.gz.

File metadata

  • Download URL: naturalsort-1.0.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for naturalsort-1.0.tar.gz
Algorithm Hash digest
SHA256 c92da431e12730ee348227241af6b7b43430dc04ee2a428c852b409971260145
MD5 51c031de79fcc3f9e301421b0419ec0e
BLAKE2b-256 c006924dbe761f30f7db2ee9854433c4b8387c74a8333881fc44452101df62bd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page