#traditional way to use sort function .... but in one liner function
def minus(a,b):
return a-b
print(minus(12,10))
#why use lambda ... when you want to create simple expression then use the lambda function ... example
minus_lambda = lambda x,b:x-b
print(minus_lambda(10,12))
#example 2:-
def sort_number(a):
return a[1]
list_of_list = [[1,2],[12,1],[1000,0]]
# tradition way
# list_of_list.sort(key=sort_number)
#use lambda expression
list_of_list.sort(key=lambda x:x[1])
print(list_of_list)
Thanks you for commenting your questions. I will see question and respond you.