Function numeric_sort::cmp

source ·
pub fn cmp(a: &str, b: &str) -> Ordering
Expand description

Performs a lexicographic comparison of the Segment sequences of two strings.

This has the effect of ordering the strings with respect to Number and Text substrings.

assert_eq!(cmp("apple", "cable"), Ordering::Less);
assert_eq!(cmp("32454", "hello"), Ordering::Less);
assert_eq!(cmp("file-10", "file-3"), Ordering::Greater);
assert_eq!(cmp("test-v1.10.25", "test-v1.9.2"), Ordering::Greater);
assert_eq!(cmp("agent-007", "agent-7"), Ordering::Equal);