You are required to write a program to sort the (name, age, height) tuples by ascending order where name is string, age and height are numbers. the tuples are input by console. the sort criteria is: 1: sort based on name; 2: then sort based on age; 3: then
Answers
Answered by
2
You are required to write a program to sort the (name, age, height) tuples by ascending order where name is string,. # age and height are numbers. The tuples are input by console
Answered by
4
Answer:from operator import itemgetter
persons = []
while True:
line = raw_input("> ")
if not line:
break
persons.append(tuple(line.split(',')))
persons = sorted(persons, key=itemgetter(0,1,2))
for person in persons:
print ','.join(person)
Explanation:
Similar questions