I have a lists like the below:
list1 = [['4.00', '7.00'], ['4.00', '4.00'], ['4.00', '1.00']]
list2 = [['4.00', '7.00'], ['1.00', '7.00'], ['6.00', '7.00']]
If x values are equal, I want to sort the elements in ascending order based on y values and if y values are equal, want to sort based on x values like below:
sorted list1 = [['4.00', '1.00'], ['4.00', '4.00'], ['4.00', '7.00']]
sorted list2 = [['1.00', '7.00'], ['4.00', '7.00'], ['6.00', '7.00']]
I tried to use sorted(). But code becomes complicated when i try to compare the values of x to find out if they are the same and then giving key to sorted() based on that. Can I do it in a better way?
yvalues, and they're still equal, why would going back toxchange anything? You're only testingywhenxwas equal, so going back toxis pointless.