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}]

Return the sorting indices

This can be helpful if you only want to get the sorted indices returned, that makes the performance-critical part useful for custom sorting use cases:

items = ['item 1', 'item 10', 'item 3']
print(natsort(items, return_indices=True))  
# [0, 2, 1]

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

If you're not sure about the file name format, learn more about wheel file names.

natsort_rs-0.1.15-cp314-cp314-win_amd64.whl (116.8 kB view details)

Uploaded CPython 3.14Windows x86-64

natsort_rs-0.1.15-cp314-cp314-manylinux_2_34_x86_64.whl (216.8 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

natsort_rs-0.1.15-cp314-cp314-macosx_11_0_arm64.whl (186.9 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

natsort_rs-0.1.15-cp314-cp314-macosx_10_12_x86_64.whl (194.8 kB view details)

Uploaded CPython 3.14macOS 10.12+ x86-64

natsort_rs-0.1.15-cp313-cp313-win_amd64.whl (116.8 kB view details)

Uploaded CPython 3.13Windows x86-64

natsort_rs-0.1.15-cp313-cp313-manylinux_2_34_x86_64.whl (216.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

natsort_rs-0.1.15-cp313-cp313-macosx_11_0_arm64.whl (186.9 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

natsort_rs-0.1.15-cp313-cp313-macosx_10_12_x86_64.whl (194.8 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

natsort_rs-0.1.15-cp312-cp312-win_amd64.whl (116.8 kB view details)

Uploaded CPython 3.12Windows x86-64

natsort_rs-0.1.15-cp312-cp312-manylinux_2_34_x86_64.whl (216.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

natsort_rs-0.1.15-cp312-cp312-macosx_11_0_arm64.whl (186.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

natsort_rs-0.1.15-cp312-cp312-macosx_10_12_x86_64.whl (194.8 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

natsort_rs-0.1.15-cp311-cp311-win_amd64.whl (116.2 kB view details)

Uploaded CPython 3.11Windows x86-64

natsort_rs-0.1.15-cp311-cp311-manylinux_2_34_x86_64.whl (217.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

natsort_rs-0.1.15-cp311-cp311-macosx_11_0_arm64.whl (187.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

natsort_rs-0.1.15-cp311-cp311-macosx_10_12_x86_64.whl (195.4 kB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

natsort_rs-0.1.15-cp310-cp310-win_amd64.whl (116.2 kB view details)

Uploaded CPython 3.10Windows x86-64

natsort_rs-0.1.15-cp310-cp310-manylinux_2_34_x86_64.whl (217.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

natsort_rs-0.1.15-cp310-cp310-macosx_11_0_arm64.whl (187.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

natsort_rs-0.1.15-cp310-cp310-macosx_10_12_x86_64.whl (195.4 kB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

natsort_rs-0.1.15-cp39-cp39-win_amd64.whl (116.2 kB view details)

Uploaded CPython 3.9Windows x86-64

natsort_rs-0.1.15-cp39-cp39-manylinux_2_34_x86_64.whl (217.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

natsort_rs-0.1.15-cp39-cp39-macosx_11_0_arm64.whl (187.6 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

natsort_rs-0.1.15-cp39-cp39-macosx_10_12_x86_64.whl (195.4 kB view details)

Uploaded CPython 3.9macOS 10.12+ x86-64

File details

Details for the file natsort_rs-0.1.15-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: natsort_rs-0.1.15-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 116.8 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for natsort_rs-0.1.15-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 cb27cdbbb0d4a460151b1afbaca0e716d4ca3dabd77939f3de4cc55c89668081
MD5 6a7be040016d4be3e037c6001aca9363
BLAKE2b-256 d37812fd8618086767695c5dccf5e621d79df757d6a8e754ce9225790b166088

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.15-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 315c5cd5d385ff107739d225c8678a8576d2e8878cc1c984aa4017c77acbb4af
MD5 52f325597d4edd91fa7d10b033f264fe
BLAKE2b-256 7628707b645b8cbb8c7d1580cc97124f6223cac7f906c1218c22f49d4d18d3ca

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.15-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1d829f3d9476b536a0243c32f23dbf8c7989d7ef8bc598d666bab3d7a05d6c22
MD5 627023497c8dfd3f62f75e0adab56033
BLAKE2b-256 a1165494adec3562616a552e80849ad72f35fdc88e973e10cfa32c2223a2f631

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp314-cp314-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.15-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 aa51ab0e3eb095c2f8a7ad8d565a71de18a54c2578c3aa964f9f8b8132826d19
MD5 45d197cba6ea01e80589a5bbcd18a261
BLAKE2b-256 775c43b13104b571fde52e8913ddbd2e86081e327e66fe28fe64cf4568d1f6f8

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: natsort_rs-0.1.15-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 116.8 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for natsort_rs-0.1.15-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 dbb03ec25c9005b93f9b2d77ad6ed4eda41c5f0a5e22093fa21381f3ee48c415
MD5 aa6ca837c6e96d46ca0339c16b258291
BLAKE2b-256 fe821c9ea5424ae88820234a40495cd24e05b877a40abd10130f600a9e2e0446

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.15-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ecc04074e32616a8e380fd541f8aa388159a00828a7cc06bb66f410cf747b8ff
MD5 642aeb4d39f248a812618b583bf90af4
BLAKE2b-256 fefaa69ccf72fe589ad1a663ef733c620ebfa66bcf4f763747e90a9fbaec575f

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.15-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 41455168f67f5b74fe6d4ec52e06e98304271666c29ff4d9f24da7a74dc32abe
MD5 58eedee97e97a2bacbb25899f58caec0
BLAKE2b-256 7020e0e853170eae2be5cd54f973d81fd4541cc6d86dd6e8354a41ddf3bf8d59

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.15-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ca33eaa346d7e5ece5bc08afa72c083daf96bfd3a03800ec6edeed46fbca6fc0
MD5 58d248c7d9d5eb30dd8e57fae912ebb5
BLAKE2b-256 eda1cb676bf977e38105a51308dba8c29e429e84803ab4c1f6ea0493f5c6e6d1

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: natsort_rs-0.1.15-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 116.8 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for natsort_rs-0.1.15-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 504c4d16e4e00e554c89fbb3dbb41c5354de0288316666518df849b22ece4226
MD5 5e397937256045f40278b8184e9db424
BLAKE2b-256 fa8a5961f87c2efcb193ca1908bdd4a2c44652586211c72fc3576f9598551184

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.15-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 508ce3ef705362f76a3614048cf2fb24d3eb24b732676e6706d92a2c51c3dad2
MD5 13cc2dc378f34fe8c435b67e6fe9fde9
BLAKE2b-256 2bb301883b7878dd9c63251b83b6ebb8335a8383b3a95e4a3f24c688c2587dfd

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.15-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4aed442ab5dae74d810d50528cec01d6c688397e163504e156103edaf10184ef
MD5 1fec587bc6e0b92f9c573c5b75626a58
BLAKE2b-256 ecb37700af9da78cb46393fd5a62540145225acb2b6ba6e27c5c5232417e4dd9

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.15-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d78e1502bffd4786ac5b3c19ff2908ca2768ff773a7864262976a5ae198bde70
MD5 6a9cb493d366a92983f8a78b2cbd5c6b
BLAKE2b-256 ec8e997d897ba9f2dede9142c811bc8a9fcaac2411da29025e6e37417039bed3

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: natsort_rs-0.1.15-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 116.2 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for natsort_rs-0.1.15-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 90f4061abbce20d49c9ee37eb41e200d6ca6f67b9d2cf481520098df438c22d8
MD5 a788a1426d6ec42120fa26fcdd1f2df5
BLAKE2b-256 1c7272603a10e6f4e57bcc941abea9b2ec0e7c7bad03f7cfdd0e444cff5ee54c

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.15-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a39d1ce0b929281df305ce3999ead6b6992d817b5813e5405037ac5208811c01
MD5 e9c324fde09664bb0e5b88d08e8e56b0
BLAKE2b-256 76d2ff39ff10c10de548f5fa5556186ba4e18fb50219e39230339928bdef21cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for natsort_rs-0.1.15-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9f403d2254538857f597b29f2f192435d08737a17e305fda697b6dbf01cdbace
MD5 e53203b1d369bee5b5f68cf0232f238b
BLAKE2b-256 d64dd78dd520f9dc07886f4ee846fee3c2a06affcb12afa3b85ccf94f3fb7949

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.15-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0fb0440642de02d24416a03e432e7d0b2e5a1a9194ea8b809d85d81ad2e2102b
MD5 06b3bb9276d89ffeb06bdd726c72978d
BLAKE2b-256 57b2eb8dddd98ba4c4a7f84320388f8f1ebe0906e320379d4f9b64c79daeb68a

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: natsort_rs-0.1.15-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 116.2 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for natsort_rs-0.1.15-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 852873d76d550460cda233ce4bee2df2083dd5ed15505b7d3e4794f8883a67a9
MD5 b26c6bc9179653721290f2e00d65703d
BLAKE2b-256 b25a4838ea4a17a7ca528be0e4d805938da7cb7f5d4818ee9bcfa8b075e561e1

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.15-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 8d00f3c1287cb72266dd6da40fc54681f5148e0b72a23fa94619ee2dcbd5cfd4
MD5 00d2abe7a421091b5dcecb9d2ac424b5
BLAKE2b-256 e3b79527f561dea283579ec5487ce37b8c5946b2efd9aa71bc2a8be58c119408

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for natsort_rs-0.1.15-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 378f5524077f47e71a2f26c3ba55f6b08cab173a33e8792734d6be7aedbfad91
MD5 0213af69e205f57f849c48f1c542456c
BLAKE2b-256 f36868f29b5cbdd1271931bc27b9062c614f3113c55f72ea242ae4ffee4839fb

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.15-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b4c5f82dd4258fdee3e833d93a9cc4b4a2ed2d0e78b4d6a9716ca1d4c225b839
MD5 51269bdc0d00fdaed259ad4ac87f8b2c
BLAKE2b-256 7753747ce7f987c4e06765b7bdf84886869b2ea80f6765b74d8f5f9f2a1c2491

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: natsort_rs-0.1.15-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 116.2 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for natsort_rs-0.1.15-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 fa41de4bd2fd9190c7785cfe252d135c47ebf45cccfe817b7dfd3aa91857e8d4
MD5 3890eee81bb9320c496ac50a8a9fd044
BLAKE2b-256 e6872c1fb474eabd48c62acb09e3eba3de5e37ecaf464e7b16ec59ff0f9829ec

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.15-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 bfe346bbdf461b611e09fba02011fbbf37b51b4a206478dd1788adf854b5af64
MD5 956cfa2f93b065a14fb227cdee995e06
BLAKE2b-256 d05762351448757d3c994386a1e3d15617acb1220530bebc34f3c6f92f3eefa1

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.15-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8f1d5ddde022a057db796cdb7d65195fc7f7c8eb337d2a48c3cfd5b7377399d5
MD5 e8fca99cde91edfed57399c6d3c10e3e
BLAKE2b-256 c3ecddef3b0391f220ff9caae1da69ad98132efb63a3d562ab65ba6748c7790b

See more details on using hashes here.

File details

Details for the file natsort_rs-0.1.15-cp39-cp39-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for natsort_rs-0.1.15-cp39-cp39-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 52399f4ad47ac3bcf9ab8904b3609b1ac88fdeee81a90e49fb38aad0c9a4a1f4
MD5 47d75e2f422bed83c4686caf71a642d6
BLAKE2b-256 2c70391e7b158de02e2d04796d2eaaca106f1556f4432ded88f954b2a7304204

See more details on using hashes here.

Supported by

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