[CentralOH] Python reversed() Question

Kris Hardy kris at rkrishardy.com
Fri Apr 20 03:19:15 CEST 2012

On 4/19/2012 7:16 PM, Kris Hardy wrote:
> sorted([("D3","E4"), ("A3","B2"),("A2","C4")...], lambda item: item[1])
sorted([("D3","E4"), ("A3","B2"),("A2","C4")...], *key=*lambda item: 
> On 4/19/2012 7:12 PM, Fandi Peng wrote:
>> Hi guys, I have a question:
>> Suppose I have a list, every element in the list is a tuple,
>> every tuple has two elements,
>> e.g. [("D3","E4"), ("A3", "B2"), ("A2","C4")....]
>> Therefore, if I sorted the list, the tuples would be rearranged
>> based on the first element of each tuple:
>> e.g. [("A2","C4"), ("A3", "B2"), ("D3","E4")....]
>> Now I want this list to be sorted based on the second element
>> of each tuple:
>> e.g. [("A3", "B2"), ("A2","C4"), ("D3","E4"),....]
>> What's the simplest code could you come up to achieve
>> this?
>> _______________________________________________
>> CentralOH mailing list
>> CentralOH at python.org
>> http://mail.python.org/mailman/listinfo/centraloh

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/mailman/private/centraloh/attachments/20120419/a71ab26f/attachment.html>

More information about the CentralOH mailing list