another way to sort like l.sort(key=lambda x:(x, -x))
sajuptpm at gmail.com
Tue Sep 7 15:24:06 CEST 2010
I have a list of tuples.
l = [((30,50),(70)), ((50,20),(20))]
for i in range(10):
k = ((i+30,i+50),(i+70))#suppose creating new tuple in each iteration
using some random value and in sert it into list.
for i, v in enumerate(l):
if v >= k:
flag = False
This code will give a list of tuples sorted in asc order.
I need to change this code to sort this list by k ascending and
What are the modifications needed in this code.
I dont want to user sort() method of list.
i need to implement l.sort(key=lambda x:(x, -x)) in
another way .I want to know what the modification needed in the 'if'
check to sort this list of tuples in k ascending and k
More information about the Python-list