so I recently wrote a function that sorted using the last value in a tuple. Obviously this couldn't be done simply say sorted(tuples, key=tuples[-1]) because that is not a "legal" call. However I did run across, while trying to figure out how to make things like this work, the utilization of lambda so the code became.
def sort_last(tuples): x=sorted(tuples, key=lambda tuples: tuples[-1]) return(x)
The code runs correctly and, that's all well and good, but I don't understand why lambda tuples"or any given var for that matter":. makes this possible. Can someone explain this to me in a way I'll understand so that I can utilize the principle to its maximum potential?
p.s. I have essentially no calculus experience.