Crates.io | natord |
lib.rs | natord |
version | 1.0.9 |
source | src |
created_at | 2014-11-21 01:24:19.996546 |
updated_at | 2015-12-16 00:01:49.263868 |
description | Natural ordering for Rust |
homepage | https://github.com/lifthrasiir/rust-natord |
repository | https://github.com/lifthrasiir/rust-natord |
max_upload_size | |
id | 204 |
size | 10,577 |
Natural ordering for Rust. (also known as rust-natord
)
This allows for the comparison like this:
let mut files = vec!("rfc2086.txt", "rfc822.txt", "rfc1.txt");
files.sort_by(|&a, &b| natord::compare(a, b));
assert_eq!(files, ["rfc1.txt", "rfc822.txt", "rfc2086.txt"]);
It provides a compare
and compare_ignore_case
function for comparing strings,
and also a compare_iter
function for the customizable algorithm.
There are multiple natural ordering algorithms available.
This version of natural ordering is inspired by
Martin Pool's strnatcmp.c
.
See the test cases in the source code to see what it can do and it cannot.
Natord is written by Kang Seonghoon and licensed under the MIT/X11 license.