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
Release history Release notifications | RSS feed
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
Close
Hashes for natsort_rs-0.1.8-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3aa29dbc2015dc14b1ca4b4fcd216c8c0e8df3b4e1e1d115d1b4a8fa8d38fe9d |
|
MD5 | 1353b66962f20b6bafa9bb85c51e2326 |
|
BLAKE2b-256 | 1c92b63e24952f10dd2d47a29c28cce621d35062328cf32167cc0f037312e81f |
Close
Hashes for natsort_rs-0.1.8-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cdda797788cd8d8e047fccb40ea1976d5c00e01913fb0ac6d4380437a760404 |
|
MD5 | daf1443a7a61282678ee62edca2b8f42 |
|
BLAKE2b-256 | 74ba68808c0db03374b011462568421bded32248a3795683eb723e5a5a302c82 |
Close
Hashes for natsort_rs-0.1.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1849ede7ec9d3a457c1eb6a55fd2ef4afa2bcee5a885bcde8fa852a46dd7da2 |
|
MD5 | 49f5276da6c82e23c46c11f8052cc025 |
|
BLAKE2b-256 | 09419ed2d8c7ab7efcc0d4e5bab43f36cb5fbc0d653f750b487e6b064831c2db |
Close
Hashes for natsort_rs-0.1.8-cp311-cp311-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bf202e247209a7a8ac2e443213a38164b94a1ec46a6118f607b3ccc5ba3f1e2 |
|
MD5 | 2c2402173491c313f32d412884300d0b |
|
BLAKE2b-256 | ccf9882112d64b36e6ab7b55ecf6757e65783df7edb43ef378e40854e7a1dbd1 |
Close
Hashes for natsort_rs-0.1.8-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10d4d61c027a38c22d93c841494f6b20a8856b8a2cbd1ef1e630061e192ff2ce |
|
MD5 | ff6717a574530e813dc7387ee1dca5b6 |
|
BLAKE2b-256 | ebb089c54dd4f668cb33ff60b6eb22070609edf5e4e7276e9131830e382d2062 |
Close
Hashes for natsort_rs-0.1.8-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d36a3f87f01324ee2d90ef9d0871eb15c4cfc2bbf69212361674bc089fec7ba4 |
|
MD5 | e1deb716588a4fabbb319ae20e75e5d4 |
|
BLAKE2b-256 | 6c26c856f32b9df24101380f13a1012e8d620e78abb1946483f2c350301786f3 |
Close
Hashes for natsort_rs-0.1.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3e2560b761664875ce5e2bbd6bc175b1aa1d86763349b5328a33a4196c0ac86 |
|
MD5 | d4b2d63beed004772299344df057d251 |
|
BLAKE2b-256 | e0a1c74c6c77513bdd60b13520e2823329afe90abcb2eb3d94ac9168d207ec80 |
Close
Hashes for natsort_rs-0.1.8-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebcbab07263e0f1df4f16ea5a2a1505dc57390a5b3b098adc7123f994d3378b1 |
|
MD5 | d7775a0b6cea501e34141607cff002cc |
|
BLAKE2b-256 | cf126c04e66809e9bb81941599563a5961e88b94ebdcbd37acf28a862c6c53c1 |
Close
Hashes for natsort_rs-0.1.8-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5b482bbdd9261be2f04605a5b8be09a561032ff6db1843d2e37e11c22681c62 |
|
MD5 | ce96a206073773b139b131d4885e7e2e |
|
BLAKE2b-256 | b8744b1bf7dc35a8e6716b0b0f4ce168d15fb08a3e0dbd74031b8ee0655ae21d |
Close
Hashes for natsort_rs-0.1.8-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e390a71116316cc7b4afab7b764b5bd17af1e06bbb16454da1161e12c486f7b |
|
MD5 | cdd6ff86cc7eb3158b3da9f5d5d54ff4 |
|
BLAKE2b-256 | 27f673d35fbb4405c5dbfab7c04989a4c9651470cf7fb62b3ed7903d76065f2c |
Close
Hashes for natsort_rs-0.1.8-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd019f6fba3ad98357f2d5f768e4f343991ce9409726be437461ef94a6357712 |
|
MD5 | 2b19bca98c4cd2d843c758ca7b54aa01 |
|
BLAKE2b-256 | 8d34f52e9901127b511861027c809c9e2531a08d0933bff6e4a146077f86cdc9 |
Close
Hashes for natsort_rs-0.1.8-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01ac55d5e8ae16333d5f2c96002055541690a14211ac91d03d2fff108d009e2d |
|
MD5 | 23bf9cd374371830c6853b4a6c4286ee |
|
BLAKE2b-256 | 70798cf9f0967735a38060c7574de16cf74e466d9dc176cdf5551479ee546635 |
Close
Hashes for natsort_rs-0.1.8-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3cf0f50922e2cbe1670c75789314639e7075bdd97ea5626466c3ca8ca466074 |
|
MD5 | 94e944f6e2a5819ab83579dd4c8b6f59 |
|
BLAKE2b-256 | 178f782c3561638e8018f1a01171b00d8cbf0c90264285f0eef27be5f36d0e54 |
Close
Hashes for natsort_rs-0.1.8-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f11e0e44d333fd36b4e00cbe409718f3101c07c5eba0c3d7683065b89052559d |
|
MD5 | 8c73c74fe362096711afa6f2dcfb880b |
|
BLAKE2b-256 | cbd3d556ddec23d3388e6ed95354e7ea0cc4e50f1fb562362ac48d1f61cc9fad |