I very much agree that this would convenient.
However, such design has some costs:
- Need new
permutationtype, for which this would be the only use case sortimplementation/API gets more intricate- It is not immediately obvious that
sortdoes not do sorting. For example, some reviewer will end up scolding a junior coder for doing multiple O(nlogn), when in reality he wasn’t and was just privy to immediately non-obvious implementation detail
I think very similar can be achieved without drawbacks above, while still being sufficiently close to what you are pointing at:
def list.reorder(self, order):
...
# Then your suggested above becomes:
idxs = sorted(range(len(keys)), keys=keys) # o(NlogN)
# using permutation type for sorting without recomputing order
values1.reorder(idxs) # o(N)
values2.reorder(idxs) # o(N)
This way, design is more modular and instead of putting more strain on sort we can develop a new method. And reordering in general has some scope to explore - order input has 2 fundamental forms, equal-sized block reordering, etc.
So I think this would be a very valid direction to take a look at, but I think it is best left as a separate endeavour.