sortBy package:turtle

Return a list of the elements of the given Shell, sorted by the given function and keeping duplicates:
>>> sortBy (comparing fst) (select [(1,'a'),(4,'b'),(2,'c'),(3,'d'),(3,'e'),(7,'f')])
[(1,'a'),(2,'c'),(3,'d'),(3,'e'),(4,'b'),(7,'f')]