Simple natural order sorting API for Python that just works


The ``natsort.natsort()`` function in the ``naturalsort`` package is a very simple alternative to Python's ``sorted()`` function that implements `natural order sorting`_ in Python. The package is available on PyPI, so getting started is very simple:

  $ pip install naturalsort
  $ python
  > from natsort import natsort
  > versions = ['1.8.1-r26', '1.8.1-r30', '2.0-r2', '2.0-r7', '2.0-r11']
  > natsort(['my-package-%s' % v for v in versions])

The main use case that this package was originally created for is sorting of pathnames with versions numbers embedded in them. This is why the sorting key defined by the ``naturalsort`` package ignores filename extensions (not doing so can give unexpected results).

Upload more screenshots

Please help extend the collection of screenshots. Just make a screenshot and upload it here. You don't need to register or anything.

Upload a screenshot

Hint: upload an image here from your clipboard with Ctrl-V

Install this software package

If the package is available for the distribution you are currently using on your computer then install the software by clicking on…

Install python-naturalsort