natsort
Simple yet flexible natural sorting in Python.
Decision gist · record as of 2026-08-14
Yes. natsort is actively maintained, has no dependencies, carries a permissive MIT license, and solves a common sorting problem cleanly. It's in the top 1000 PyPI packages by download volume and has been stable since its 2012 release. Install it if you need to sort strings containing numbers in a human-readable way.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low install friction; pure Python wheel with no runtime dependencies.
- Actively maintained with recent commits and stable production status.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use, modify, and distribute natsort freely in commercial and private projects with minimal restrictions.
last release 2023-06-20 (1151 days) · last repo commit 2026-08-05 · 1,015 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 25,952,714 downloads/mo, #898 on PyPI
Alternatives
Verify before relying
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']- Whether PyICU is required or optional for non-Windows locale-aware sorting (documentation suggests optional but recommended)
What it is and what it does
natsort is a Python library that sorts strings containing numbers using natural (human-readable) ordering instead of the default lexicographic sort. When Python's built-in sorted() encounters a list like ['1 ft 5 in', '10 ft 2 in', '2 ft 7 in'], it orders them as ['1 ft 5 in', '10 ft 2 in', '2 ft 7 in'] because '10' comes before '2' alphabetically. natsort's natsorted() function instead produces ['1 ft 5 in', '2 ft 7 in', '10 ft 2 in'], treating embedded numbers as numeric values.
The library offers several convenience functions and customization options: natsorted() for basic natural sorting, realsorted() for treating numbers as signed floats, humansorted() for locale-aware sorting, and os_sorted() for file-browser-like path ordering. You can combine algorithm modifiers using bitwise OR to mix behaviors like REAL, LOCALE, and IGNORECASE. It has no runtime dependencies and supports Python 3.7 and later.
Use it for
- Sort version strings like 'v1.9', 'v1.10', 'v2.0' in the correct numeric order
- Sort file paths the way your operating system's file browser would display them
- Sort scientific data containing signed floats embedded in strings
- Sort mixed alphanumeric identifiers (e.g., 'item1', 'item10', 'item2') naturally
- Implement locale-aware human sorting that respects language-specific character ordering and number formatting
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
natsort is actively maintained, has no dependencies, carries a permissive MIT license, and solves a common sorting problem cleanly. It's in the top 1000 PyPI packages by download volume and has been stable since its 2012 release. Install it if you need to sort strings containing numbers in a human-readable way.
Install
natsort on PyPI
Before you install
Low install friction; pure Python wheel with no runtime dependencies. Actively maintained with recent commits and stable production status.
License in practice
MIT license is permissive; you can use, modify, and distribute natsort freely in commercial and private projects with minimal restrictions.
Quickstart
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']
Verify before relying
- Whether PyICU is required or optional for non-Windows locale-aware sorting (documentation suggests optional but recommended)
Package 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,151 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 25,952,714 / month, #898 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Financial and Insurance IndustryIntended Audience :: Information TechnologyIntended Audience :: Science/ResearchIntended Audience :: System AdministratorsLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Scientific/Engineering :: Information AnalysisTopic :: Text ProcessingTopic :: Utilities |
Evidence: natsort-8.4.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “natural sort numbers in strings”
- natsortnatsort provides natural sorting for strings containing numbers,…
- lexidGenerates lexically ordered numerical IDs that maintain sort order…
- humanizeConverts numbers, dates, times, and file sizes into human-readable…
Give your agent the search over MCP, or paste the wish link into any chat.
More Utilities packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.
Install it if you need to display or transform source code.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
See also csvsort · pyuca · sort-lines · zope.sequencesort · usort · toml-sort · toposort · sortedcollections · inventree-ipn-generator · ordered-enum