Alphabetize output and cleaned up code