Improved sorting the list