Sorting list after generating it