You could sort it once, then go over the entire list and relabel the entries in ascending order. That should not be too hard if you already managed to sort them.
If your values are all strings you...