| ▲ | hinkley 4 hours ago | ||||||||||||||||
I can’t think of a single time I’ve needed a sorted list of only numbers. It’s always numbers and something else, like names or dates. Maybe for median calculations, but I don’t even use those that much either. Especially in telemetry, where mean is easy and median is not. | |||||||||||||||||
| ▲ | pvillano 4 hours ago | parent | next [-] | ||||||||||||||||
To be pedantic, median is cheaper than sorting. O(n) with a quicksort-like algorithm. Also, if you're taking an average of floating point numbers, you might want to sort it first and add from smallest to largest, to better preserve precision | |||||||||||||||||
| |||||||||||||||||
| ▲ | vlovich123 4 hours ago | parent | prev [-] | ||||||||||||||||
If the primary key is the number, it still works (and dates are just numbers by the way) because you can sort a heterogenous dataset by a single numeric key pretty trivially. But sorting by arbitrary strings like names can’t avoid comparison sort. | |||||||||||||||||