#sorting #human #order #natural

human-sort

Human sort (natural sort) implementation

16 releases

0.2.2 Apr 14, 2019
0.2.1 Feb 5, 2019
0.1.14 Jan 28, 2019

#740 in Algorithms

Download history 2279/week @ 2023-11-30 2392/week @ 2023-12-07 2837/week @ 2023-12-14 1994/week @ 2023-12-21 1858/week @ 2023-12-28 2521/week @ 2024-01-04 3006/week @ 2024-01-11 2464/week @ 2024-01-18 2344/week @ 2024-01-25 3147/week @ 2024-02-01 3098/week @ 2024-02-08 3374/week @ 2024-02-15 2796/week @ 2024-02-22 3102/week @ 2024-02-29 2833/week @ 2024-03-07 2519/week @ 2024-03-14

11,629 downloads per month
Used in 29 crates (15 directly)

MIT license

6KB
61 lines

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.


lib.rs:

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);

No runtime deps