Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

tl; dr, but a quick note: the presented algorithm takes the first element as the pivot element p:

   qsort (p:xs) = ...
This is not recommended as it results in worst-case behavior on sorted input lists. (Another commentor correctly pointed out that it requires extra memory for the intermediate lists, too.)


It is just a toy implementation. If we're going to worry about practicals, then it's not recommended to use your own general purpose sorting implementations at all. For general purpose sorting, the standard library "always" has the best implementation.


Except it is also the canonical look-how-awesome-Haskell-is example that keeps getting trotted out all the time. Why aren't there more canonical examples of Haskell being both simple and awesome as well as fast and correct?


Any knowledge about your data set, how much of it varies, etc can vastly improve your performance over any canned standard library solution. Sorting ints? Radix-sort that mofo.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: