#sorting #string #ascii #characters #ascii-text #convert #vec

stringsort

Pathological sorting of string characters

3 stable releases

Uses old Rust 2015

2.0.1 Jan 10, 2024
2.0.0 Aug 7, 2016
1.0.0 Aug 7, 2016

#1214 in Algorithms

Download history 8/week @ 2024-01-08 16/week @ 2024-02-19 23/week @ 2024-02-26 13/week @ 2024-03-11 5/week @ 2024-03-25 38/week @ 2024-04-01

56 downloads per month

MIT/Apache

7KB
149 lines

Sort characters of a string (eg asdf => adfs). Exposes 3 methods, all taking an &str to return a String

vecsort: Converts arg into Vec, sorts Vec, converts Vec to String insertsort: Builds a string by employing linear insert sort on each character countsort_insert: Builds a string by counting the occurences for all ascii characters, building up a sorted string of nonascii characters with insert sort, then generates a string based off counts of ascii characters & appends nonascii countsort_vec: Similar to countsort_insert, but buffers nonascii as a vector to sort afterwards

insertsort is good for very small strings, bucketsort is good if you expect mostly ascii, vecsort is the only one that isn't worst case quadratic NB bucketsort is O(N) for ascii strings

No runtime deps