5 ms·
Thinking this through some more, using sort with a comparator function would be unnecessary slow. Given the objective of the algoritm (return a median), it's mu
by meryn 13y ago
Thinking this through some more, using sort with a comparator function would be unnecessary slow. Given the objective of the algoritm (return a median), it's much better to convert the array of strings to an array of floats (or ints, whatever he wants) first.
- sesqu 13y agoOr to simply use a selection algorithm instead of a sort, since they are asymptotically faster.