Help with using sorted in python pls

Hello, I am trying to sort a list by the second element index[1] of the tuple but it’s not working. in this example. i want to sort by insurance cost instead of name

medical_records= list(zip(names, insurance_costs))


sorted(medical_records, key=lambda record:record[1])

print("Here are the medical records sorted by insurance cost: " + str(medical_records))
Thank you in advance!

The sorted function does not act on the existing list. It creates a new one. You can either use the .sort() method of the existing list or you can work with what sorted returns.