May-04-2020, 02:22 PM
@anbu23 and @DeaD_EyE thanks for your replies.
Here's the code if anyone needs it in the future :
Here's the code if anyone needs it in the future :
def sort_last(tuples): for t in tuples : last_element = t[-1] return sorted(tup, key=lambda x:x[-1]) tup =[ (1, 7), (1, 3), (3, 4, 5), (2, 2)] print(sort_last(tup))And output :
Output:[(2, 2), (1, 3), (3, 4, 5), (1, 7)]
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs