| 1 | struct Options { |
| 2 | } |
| 3 | |
| 4 | fn sort_dictionary_order(mut lines []string, options Options) { |
| 5 | map_fn := fn (e u8) u8 { |
| 6 | return if e.is_digit() || e.is_letter() || e == ` ` { e } else { ` ` } |
| 7 | } |
| 8 | lines.sort_with_compare(fn [map_fn] (a &string, b &string) int { |
| 9 | aa := a.bytes().map(map_fn).bytestr() |
| 10 | bb := b.bytes().map(map_fn).bytestr() |
| 11 | return compare_strings(aa, bb) |
| 12 | }) |
| 13 | } |
| 14 | |
| 15 | fn test_main() { |
| 16 | mut a := ['a', 'b', 'c'].reverse() |
| 17 | sort_dictionary_order(mut a, Options{}) |
| 18 | assert dump(a) == ['a', 'b', 'c'] |
| 19 | } |
| 20 | |