num = (1, 2, 3, 0)
va = []
listnum = list(num)
absnum = ([abs(n) for n in sorted(num)])
D = {k: v for (k, v) in zip(range(len(num)), absnum)}
N = sorted(D, key=D.get)
for x in N:
p = listnum.pop(x)
va.append(p)
listnum.insert(x, None)
print(va)
Why it print [1, 2, 3, 0] but not [0, 1, 2, 3]
Created at: 2014/08/21 13:44; Updated at: 2019/05/03 20:49