Skip to main content

A blazing fast natural sorting library for Python

Project description

natsort-rs

🚀 A blazing fast natural sorting library for Python written in Rust 🦀

Installation

pip install natsort-rs

Usage

from natsort_rs import natsort

Sort a list of strings

items = ['item 1', 'item 10', 'item 3']
print(natsort(items))  
# ['item 1', 'item 3', 'item 10']

Sort case insensitively

items = ['Item 1', 'Item 3', 'item 2']
print(natsort(items, ignore_case=True))
# ['Item 1', 'item 2', 'Item 3']

Sort complex objects based on property

items = [
    {'name': 'item 1', 'id': 1},
    {'name': 'item 3', 'id': 3},
    {'name': 'item 2', 'id': 2}
]
print(natsort(items, key=lambda d: d['name']))
# [{'name': 'item 1', 'id': 1}, {'name': 'item 2', 'id': 2}, {'name': 'item 3', 'id': 3}]

Benchmark

No. of items Duration natsort [s] Duration natsort-rs [s] Relative speedup
10 0.00006 0.00000 16.8
100 0.00094 0.00002 44.3
1000 0.00281 0.00022 12.7
10000 0.02835 0.00262 10.8
100000 0.29712 0.03334 8.9
1000000 3.31207 0.45333 7.3

Execute benchmark.py to reproduce the results.

Credits

This Python module is build on top of the natord crate and inspired by natsort.

License

MIT License

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

natsort_rs-0.1.9-cp311-none-win_amd64.whl (122.5 kB view details)

Uploaded CPython 3.11 Windows x86-64

natsort_rs-0.1.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (222.9 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

natsort_rs-0.1.9-cp311-cp311-macosx_11_0_arm64.whl (191.7 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

natsort_rs-0.1.9-cp311-cp311-macosx_10_7_x86_64.whl (200.3 kB view details)

Uploaded CPython 3.11 macOS 10.7+ x86-64

natsort_rs-0.1.9-cp310-none-win_amd64.whl (122.5 kB view details)

Uploaded CPython 3.10 Windows x86-64

natsort_rs-0.1.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (222.9 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

natsort_rs-0.1.9-cp310-cp310-macosx_11_0_arm64.whl (191.7 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

natsort_rs-0.1.9-cp310-cp310-macosx_10_7_x86_64.whl (200.3 kB view details)

Uploaded CPython 3.10 macOS 10.7+ x86-64

natsort_rs-0.1.9-cp39-none-win_amd64.whl (122.5 kB view details)

Uploaded CPython 3.9 Windows x86-64

natsort_rs-0.1.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (222.9 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

natsort_rs-0.1.9-cp39-cp39-macosx_10_7_x86_64.whl (200.1 kB view details)

Uploaded CPython 3.9 macOS 10.7+ x86-64

natsort_rs-0.1.9-cp38-none-win_amd64.whl (122.2 kB view details)

Uploaded CPython 3.8 Windows x86-64

natsort_rs-0.1.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (222.8 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

natsort_rs-0.1.9-cp38-cp38-macosx_10_7_x86_64.whl (200.3 kB view details)

Uploaded CPython 3.8 macOS 10.7+ x86-64

File details

Details for the file natsort_rs-0.1.9-cp311-none-win_amd64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.9-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 3a25f38ae8320952b423878d7c797e1cea9557a2e77660140ed1c0a152d7509d
MD5 c2f741477f1b1bd7bec06d9cab3649f5
BLAKE2b-256 a5dbc547144ff66ac5fb352b9cfe65b6521026705d502b8c7583ead600f474cb

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9ec2df653ce1ca28d3595035d285a18e94e159afa7505b2852d6f02518d9d726
MD5 642ca60e2cfb0f48e286ca552651a1c3
BLAKE2b-256 6614d434f7a60c3f388152c13f5f5185d453e5cc99222bb641c65935a4370462

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.9-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.9-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b3fb1f2623c8bbd33f666fb6d4922a34e9223ee72bf11ef99a3bd8eba0e12d99
MD5 cce3b3f983754105d5cdace5d00ed489
BLAKE2b-256 134347b1eacfd6234e2b550379cc845c9c4b04b1e49caac584b17f26de3359e1

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.9-cp311-cp311-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.9-cp311-cp311-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 068e40ac265a841fca95794be4cf22e4486ac13b2e3622f5f0cd89b8017ffd2e
MD5 43165bf4fbe48959173a864d3b7129d8
BLAKE2b-256 c72b3e23b8636ff8909658b166c1b1807b9eb364c80a6b28a8ede5adca875d71

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.9-cp310-none-win_amd64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.9-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 9320577617ed7a9ee1a0a9e5f0e2c2322ffede4be774f9d619c3dde1fbd4bceb
MD5 8a353e9ece840a3a10137c1f6fcfe952
BLAKE2b-256 47c96284df7141c72fab7b6db9c47ac7f6dd11bffe1bc8c852ee0aa7b1eba8e8

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0d9f3b4f701eef6dc3eb1b008d93ef30c1f0b113b664253be5124d5f271d682b
MD5 0950a66432ebcaa1a8b9ecc4c449d1d7
BLAKE2b-256 cba7bc125096958398edb5ba98619a1971dffb97e6bb0fcc50c339093b1eca77

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.9-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.9-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ac373f7310a77d0de9f4ccf36aab8419b053522e0ea7fe415b2f8a3518b4ec28
MD5 906b893fafbfa2a77bef454d7c7de35c
BLAKE2b-256 7c6c7e9194dda3162dad206c82a99d9888f6231c2fc32351992cf30848e8fe98

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.9-cp310-cp310-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.9-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 04379f731a97fe8632856a58a5a77dec4e6298efd8faa275bcbbdf2692e287d6
MD5 c6b11051ecd6ac97c7736ab9b156b133
BLAKE2b-256 0cc3244693b38757fe7adb87f62c3af015a154e98f26799ddf101554a03f23a5

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.9-cp39-none-win_amd64.whl.

File metadata

  • Download URL: natsort_rs-0.1.9-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 122.5 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for natsort_rs-0.1.9-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 4d2ce1e11c0343fde3799419688d349aa0c716583bb9ad4da3d9982a6a429af3
MD5 ef3ffdb29cb181e0bce6d6613aa14572
BLAKE2b-256 1988dd59a658c20523af72725c7337922238b603de9220f4de52e05edcd4c75e

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dd4eeaad92818dc7be1e1bd1af5f9b263648dd5eab2c7829b49dd0579dc697e3
MD5 f5f483c0d4532e57404626ec107ca3ff
BLAKE2b-256 69084b2ecd69273049bdc76de33dd091391715c141fa1ff09aade47a4ebdd32c

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.9-cp39-cp39-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.9-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 cadf4d8f0be9174479d5dfab8e790c5921ffa4a47f223f4a4fb65bb13a5d52ff
MD5 35c6593e360b9729786d76226779a253
BLAKE2b-256 31331a8905c9db96f7b15e179c29133cb24189591274573b7776a784f565bd79

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.9-cp38-none-win_amd64.whl.

File metadata

  • Download URL: natsort_rs-0.1.9-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 122.2 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for natsort_rs-0.1.9-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 0e81c4eed573d1936f89670bf3a90db4a4981db6bae22f6323437449755b0f83
MD5 689d967fcf33b2a86000bd896dffad33
BLAKE2b-256 24d94c9db66b62c42efd7b552810b2d85baa56bd4d5eb215fdbe868d37e3c589

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4309a29f6162dd203dd539f240388359fb022655529649eae0c56088c21e7af4
MD5 dfa0f568527a2370cc1d36ad0c6c057a
BLAKE2b-256 8deb76e35e41cfb8e3d2d4f83e820abcabce22689c2e2690d617f57adf90cbed

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.9-cp38-cp38-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.9-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 b5c79ab669fe1df4b6da24056b70fa6bb4b3805a2696829862139d211dd2dd19
MD5 492adeb32d2e5d95f3d4e241b6c794cb
BLAKE2b-256 fd49724ab832bfd6681c8fc45c0a18baac20b4f4d4cc6d4bf3a15687a3baffec

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page