#unicode #transliteration #lexicographical #sort #emoji


Library for comparing and sorting strings lexicographically and naturally

1 unstable release

0.1.0 Mar 26, 2023

#1090 in Text processing

Download history 2938/week @ 2023-07-19 2864/week @ 2023-07-26 1897/week @ 2023-08-02 1815/week @ 2023-08-09 1751/week @ 2023-08-16 1767/week @ 2023-08-23 2023/week @ 2023-08-30 2118/week @ 2023-09-06 1719/week @ 2023-09-13 1404/week @ 2023-09-20 1837/week @ 2023-09-27 1833/week @ 2023-10-04 1524/week @ 2023-10-11 2031/week @ 2023-10-18 1752/week @ 2023-10-25 1352/week @ 2023-11-01

6,904 downloads per month
Used in 23 crates (via surrealdb)


542 lines


The lexicmp library enables comparing and sorting strings using lexicographical and natural sorting semantics. This means that any Unicode characters such as á or ß are treated like their closest ASCII character: á is treated as a, ß is treated as ss. This library also ensures that emojis are transliterated before being sorted. When using natural sorting, numbers are sorted naturally, ensuring that 50 is sorted before 100, skipping characters that aren't alphanumeric, ensuring that f-5 is next to f5. If different strings have the same ASCII representation (e.g. "Foo" and "fóò"), it falls back to the default method from the standard library, ensuring that sorting is always deterministic, and constitute a total order.

docs.rs Crates.io


  • Compare strings lexicographically
  • Compare strings naturally with support for numbers
  • Compare strings sensitively and case insensitively
  • Compare strings, skipping non-alphanumeric characters
  • Compare strings lexicographically and naturally together
  • Handle unicode characters, foreign languages, and emoji characters
  • Does not allocate memory on the heap, instead using iterators


This code is forked originally from lexical-sort, licensed under the Apache 2.0 and MIT licenses.