dic = {'Tom': 90, 'Mary':56, 'Bob':77, 'Alan': 80, 'Sunny':100} lis = [90,56,77,80,100] students = [('Tom', 90), ('Mary', 56), ('Bob', 77), ('Alan', 80), ('Sunny', 100)] def temp_function(list): print(list) return list[0] ''' print(dic) print(dic.items()) print(dic.keys()) print(dic.values()) ''' print('dic sorted:') print(sorted(dic.items(), key = temp_function)) print('lis sorted:') print(sorted(lis)) print('students sorted:') print(sorted(students, key= temp_function)) #lambda print('lambda') print(sorted(dic.items(), key = lambda x : x[1]))