That's true, but there are definitely cases where you will need to choose between, say, sort() and stable_sort(). Or where it's worth architecting your system so it doesn't need to call sort().
Knowing what sorting algorithms do and about how fast they are is useful info. And the best way to learn is to implement them yourself at least once, perhaps in some kind of algorithms class or something, even if you never plan on doing it ever again. Calling your library's sort because it would take you a few hours to implement well and risks containing bugs or corner cases is just a smart use of your valuable time. Calling your library's sort because you're a shoddy engineer who couldn't implement it yourself if you tried is sad.
I think everyone should implement their own containers every once in a while. I recently did, and it was pretty illuminating. The corner cases really bite you in the ass. It's good practice. Ditto for sorting.
Quicksort on small data sizes (ie. ones where cache latency is significant) can actually be rather terrible. Wouldn't know that if I hadn't implemented it for practice.
6
u/SirClueless Dec 03 '19
That's true, but there are definitely cases where you will need to choose between, say,
sort()andstable_sort(). Or where it's worth architecting your system so it doesn't need to callsort().Knowing what sorting algorithms do and about how fast they are is useful info. And the best way to learn is to implement them yourself at least once, perhaps in some kind of algorithms class or something, even if you never plan on doing it ever again. Calling your library's
sortbecause it would take you a few hours to implement well and risks containing bugs or corner cases is just a smart use of your valuable time. Calling your library'ssortbecause you're a shoddy engineer who couldn't implement it yourself if you tried is sad.