Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- i_xs = [(x, i) for (i, x) in enumerate(xs)]
- s = sorted(i_xs)
- sorted_xs, index_lst = unzip(s)
- def unzip(ls):
- if isinstance(ls, list):
- if not ls:
- return [], []
- else:
- xs, ys = zip(*ls)
- return list(xs), list(ys)
- else:
- raise TypeError
- [34, 23424, 1212, -2324, 34353]
- [-2324, 34, 1212, 23424, 34353]
- [3, 0, 2, 1, 4]
Add Comment
Please, Sign In to add comment