Sorting by item_in_another_list

ZeD vito.detullio at gmail.com
Wed Oct 25 08:52:24 CEST 2006


Paul Rubin wrote:

>> A = [0,1,2,3,4,5,6,7,8,9,10]
>> B = [2,3,7,8]
>> 
>> desired_result = [2,3,7,8,0,1,4,5,6,9,10]
> 
> How about:
> 
>   desired_result = B + sorted(x for x in A if x not in B)

this. is. cool.

-- 
Under construction



More information about the Python-list mailing list