Sorry if the question is confusing or stupid but basically in a sorted function I want Lambda to check the names and if they both have the same name check to see which house comes for example
def get_name(list):
return list['Names'], list['House']
would check the name then the house they’re in can lambda do the same or just take one parameter
for student in sorted(students, key=lambda studen: studen['Names']):
print(f"{student['Names']} is in {student['House']}")
PS: I’m trying to write a lambda expression that is the same as get_name
>Solution :
Simply have your lambda return a tuple:
sorted(students, key=lambda student: (student['Names'], student['House']))
Or alternatively, using the get_name function that you defined:
sorted(students, key=get_name)