I see it used in sorting, but what do the individual components of this line of code actually mean?
key=lambda x: x[1]
What\'s lambda
lambda
distances.sort(key=lambda x: x[1])
This is the function. And here x is the list, in which we are adding x[1] i.e 2nd element of list to the sort function. So, basically we are adding every list's 2nd element (i.e x[1]) to the sort function. I hope you understand this.
x[1]