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/

Please see the GitHub main page for everything else, including

  • Quick description

  • Basic examples

  • FAQ

  • Requirements and optional dependencies

  • Installation instructions

  • Testing instructions

  • Deprecation schedule

  • 1. How Does Natsort Work?
    • 1.1. First, How Does Natural Sorting Work At a High Level?
    • 1.2. Natsort’s Approach
    • 1.3. Special Cases Everywhere!
    • 1.4. Here Be Dragons: Adding Locale Support
    • 1.5. Final Thoughts
  • 2. Examples and Recipes
    • 2.1. Basic Usage
    • 2.2. Sort Version Numbers
    • 2.3. Sort OS-Generated Paths
    • 2.4. Locale-Aware Sorting (Human Sorting)
    • 2.5. Controlling Case When Sorting
    • 2.6. Customizing Float Definition
    • 2.7. Using a Custom Sorting Key
    • 2.8. Generating a Natsort Key
    • 2.9. Sorting Multiple Lists According to a Single List
    • 2.10. Returning Results in Reverse Order
    • 2.11. Sorting Bytes on Python 3
    • 2.12. Sorting a Pandas DataFrame
  • 3. natsort API
    • 3.1. Standard API
    • 3.2. Convenience Functions
  • 4. Possible Issues with humansorted() or ns.LOCALE
    • 4.1. Being Locale-Aware Means Both Numbers and Non-Numbers
    • 4.2. Regenerate Key With natsort_keygen() After Changing Locale
    • 4.3. The locale Module From the StdLib Has Issues
  • 5. Shell Script
    • 5.1. Usage
    • 5.2. Description
  • 6. Changelog

Indices and tables¶

  • Index

  • Module Index

  • Search Page

Python

Navigation

  • 1. How Does Natsort Work?
  • 2. Examples and Recipes
  • 3. natsort API
  • 4. Possible Issues with humansorted() or ns.LOCALE
  • 5. Shell Script
  • 6. Changelog

Related Topics

  • Documentation overview
    • Next: 1. How Does Natsort Work?

Quick search

©. | Powered by Sphinx 4.5.0 & Alabaster 0.7.12 | Page source