Skip unnecessary sort.

We only use the first element of the sorted list,
so getting the minimum element instead is sufficient.