anonymous function application

##sorting
##list of tuple pairs
list1=[(38,2),(3,10),(5,1),(30,8)]
print("sorted on the order of ist element")
print(sorted(list1))
##on the order of first element
print("sorted on the order of second element")
print(sorted(list1,key=lambda x:x[1]))

"C:\Users\darul Haram\PycharmProjects\pythonProject2\venv\Scripts\python.exe" "C:/Users/darul Haram/PycharmProjects/pythonProject2/venv/Lib/application(anonymous,lambda).py"
sorted on the order of ist element
[(3, 10), (5, 1), (30, 8), (38, 2)]
sorted on the order of second element
[(5, 1), (38, 2), (30, 8), (3, 10)]

Process finished with exit code 0

Comments

Popular posts from this blog

XAMPP, SQL BASIC COMMANDS

The Minion Game Hackerrank Solution

Arrays - DS | HackerRank Solutions