Much faster to find upper and lower bounds and essentially construct a hash table than to manually sort a whole list of non-trivial length.