How Can I Sort Tuples?
Im trying to write a program that has 2 variables (Integer) and that based on those variables print´s them joined and by order (Smaller number to Higher): Like this: together((0,3
Solution 1:
Why not just append both tuples and then sort them:
def together(s,t):
return tuple(sorted(s + t))
Solution 2:
T = ((0,39,100,210),(4,20))
print tuple( sorted( reduce(tuple.__add__, T) ) )
This can combine and sort N number of tuples
within a tuple, so it's not limited to two tuples
Post a Comment for "How Can I Sort Tuples?"