Skip to content

Instantly share code, notes, and snippets.

@benblack769
Last active October 20, 2016 21:10
Show Gist options
  • Save benblack769/31ebbc24718d823458066fc75f7e424b to your computer and use it in GitHub Desktop.
Save benblack769/31ebbc24718d823458066fc75f7e424b to your computer and use it in GitHub Desktop.
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