The Crystal Programming Language Forum

Feature request: more sorting algorithm options

If somebody ever has some cycles, it might be interesting to add/research into optimizing the sort algorithm crystal uses. Maybe add new options? Possibilities: “dual pivot quicksort”, “radix sort” for various primitives, “timsort” for the stable sort (objects) [or quadsort for stable? pdqsort for unstable?], “burstsort” for strings. Fun project for some day, just documenting some ideas :)

Boost’s float_sort [not sure if we want that as the default for sorting floats, though, sadly].

Mergesort seems like a fairly popular stable sort, I’ll look into it to satisfy Poll: should default sort behavior be "fast" or "stable"? (it looks less daunting than Timsort but still reasonably good, and stable LOL :)

2 Likes