natsort
Simple yet flexible natural sorting in Python.
Install
natsort on PyPI
pip
pip install natsortuv
uv add natsortpoetry
poetry add natsortPackage facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 1,150 days since the last release |
| Last repo commit | |
| First released | |
| Popularity | one of the top 1,000 most-downloaded packages on PyPI (30-day window, as of 2026-08-13) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-13) |
Evidence: natsort-8.4.0-py3-none-any.whl
About natsort
from the package's own PyPI description — quoted content, verbatim
natsort
.. image:: https://img.shields.io/pypi/v/natsort.svg :target: https://pypi.org/project/natsort/
.. image:: https://img.shields.io/pypi/pyversions/natsort.svg :target: https://pypi.org/project/natsort/
.. image:: https://img.shields.io/pypi/l/natsort.svg :target: https://github.com/SethMMorton/natsort/blob/main/LICENSE
.. image:: https://github.com/SethMMorton/natsort/workflows/Tests/badge.svg :target: https://github.com/SethMMorton/natsort/actions
.. image:: https://codecov.io/gh/SethMMorton/natsort/branch/main/graph/badge.svg :target: https://codecov.io/gh/SethMMorton/natsort
.. image:: https://img.shields.io/pypi/dw/natsort.svg :target: https://pypi.org/project/natsort/
Simple yet flexible natural sorting in Python.
- Source Code: https://github.com/SethMMorton/natsort
- Downloads: https://pypi.org/project/natsort/
- Documentation: https://natsort.readthedocs.io/
- `Examples and Recipes`_
- `How Does Natsort Work?`_
- `API`_
- `Quick Description`_
- `Quick Examples`_
- `FAQ`_
- `Requirements`_
- `Optional Dependencies`_
- `Installation`_
- `How to Run Tests`_
- `How...
Read as markdown · JSON record · Source repository · Homepage
AI interpretation — verify before relying
AI-generated interpretation of the package facts above; every digit, version, license, or vulnerability id it cites is grounded in the facts already shown on this page
natsort provides natural sorting for strings containing numbers, ordering them by numeric value rather than lexicographic order—so '10' sorts after '9' instead of after '1'.
Installs with zero runtime dependencies and is distributed as a pure-Python wheel, making it friction-free. The project shows active maintenance with recent commits and is classified as Production/Stable.
Licensed under MIT (permissive), allowing unrestricted use, modification, and distribution in both open-source and proprietary projects with minimal obligations.
Usage
pip install natsort
from natsort import natsorted
a = ['2 ft 7 in', '1 ft 5 in', '10 ft 2 in']
result = natsorted(a)
print(result) # ['1 ft 5 in', '2 ft 7 in', '10 ft 2 in']
Verdict: natsort is a mature, zero-dependency utility for natural sorting that solves a common problem elegantly. With active maintenance, no known vulnerabilities, permissive licensing, and top-1000 popularity, it is a safe and practical choice for any project needing human-friendly string sorting.
Needs verification
- Whether optional PyICU dependency improves locale-aware sorting enough to warrant installation for non-Windows users
- Performance characteristics on very large datasets compared to built-in sorted()
Similar packages
permissive · top 1,000 on PyPI
bitarraypermissive · top 1,000 on PyPI
joserfcpermissive · top 1,000 on PyPI
sortedcontainerspermissive · top 1,000 on PyPI
isortpermissive · top 1,000 on PyPI
humanizepermissive · top 1,000 on PyPI
ujsonpermissive · top 1,000 on PyPI
sphinxcontrib-applehelppermissive · top 1,000 on PyPI
tomli-wpermissive · top 1,000 on PyPI
sqlparsepermissive · top 1,000 on PyPI