Last active
October 20, 2016 21:10
-
-
Save benblack769/31ebbc24718d823458066fc75f7e424b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
names = int(input()) | |
name_data = [] | |
for _ in range(names): | |
data = input().split() | |
name = data[0][:-1] #removes colon from input | |
orddata = [s[0] for s in data[1:-1]] #gets a list of the first character of every word (note that 'u' > 'm' > 'l') | |
orddata.reverse() #string lexical comparison works from start to finish, this sort works from finish to start, so reverse it | |
name_str = "".join(orddata) | |
name_str += "m" #adding m gives the default "unnamed is medium" behaviour | |
name_data.append((name_str,name)) | |
name_data.sort(reverse=True) | |
for s,name in name_data: | |
print(name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment