1
根据a
排序两个列表(a, b)
并单独返回两个排序列表,正如下面所做的那样是正确的。排序列表 - pythonic方式
a = ['apple','carrot','banana']
b = [5,10,15]
s = sorted(zip(a,b))
a,b = map(list, zip(*s))
print a
print b
['apple', 'banana', 'carrot']
[5, 15, 10]
但是,没有更好的方式来做到这一点? Given condition: Two lists, a and b.
Result: As printed above
PS这是Python 2.7版