I'm curious why you'd choose an algorithm that on average takes O(n log n) comparisons with a O(n^2) worst case versus simply iterating O(n)?
Unless there are other requirements I don't see why you'd suggest sorting the elements.
Unless there are other requirements I don't see why you'd suggest sorting the elements.