Sorts list properly