Added user input, and got rid of a duplicate sort.