1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! `natural_sort` is a crate that deals with sorting strings using "natural
//! sorting", (also known as "human sorting").
//!
//! With normal string-based searching, strings are always compared
//! alphabetically:
//!
//! ```
//! let mut files = ["file2.txt", "file11.txt", "file1.txt"];
//! files.sort();
//!
//! // "file11.txt" comes before "file2.txt" because the string "11" comes
//! // before the string "2" in the dictionary.
//! assert_eq!(files, ["file1.txt", "file11.txt", "file2.txt"]);
//! ```
//!
//! This crate provides a function `natural_sort` which will order strings
//! numerically when doing so makes sense:
//!
//! ```
//! use natural_sort::natural_sort;
//!
//! let mut files = ["file1.txt", "file11.txt", "file2.txt"];
//! natural_sort(&mut files);
//!
//! // Here, "file11.txt" comes last because `natural_sort` saw that there was a
//! // number inside the string, and did a numerical, rather than lexical,
//! // comparison.
//! assert_eq!(files, ["file1.txt", "file2.txt", "file11.txt"]);
//! ```
//!
//! Human-comparable strings can be created directly using
//! `natural_sort::HumanString::from_str`.
extern crate regex_macros;
extern crate regex;
pub use natural_sort;
pub use HumanString;