Sorting by item_in_another_list

Paul Rubin http
Tue Oct 24 06:48:22 CEST 2006


Cameron Walsh <cameron.walsh at gmail.com> writes:
> for example:
> 
> 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)



More information about the Python-list mailing list