human-sort

Crates.iohuman-sort
lib.rshuman-sort
version0.2.2
sourcesrc
created_at2019-01-25 09:57:10.944309
updated_at2019-04-14 18:10:42.384393
descriptionHuman sort (natural sort) implementation
homepage
repositoryhttps://github.com/paradakh/human-sort
max_upload_size
id110593
size6,803
Vlad Nagikh (paradakh)

documentation

README

Crates.io Build Status

human-sort

Utilities to sort and compare strings with numeric symbols in human-friendly order.

It built over iterators and compare string slices char by char (except for numerals) until the first difference found without creating Strings or another structures with whole data from provided &str, so doesn't require lots of memory.

Examples

use human_sort::sort;

let mut arr = ["file10.txt", "file2.txt", "file1.txt"];
sort(&mut arr);

assert_eq!(arr, ["file1.txt", "file2.txt", "file10.txt"]);
use std::cmp::Ordering;
use human_sort::compare;

assert_eq!(compare("item200", "item3"), Ordering::Greater);

License

Licensed under MIT license.

Commit count: 34

cargo fmt