map_order#

rojak.core.indexing.map_order(on: list[T], by: list[int]) list[T][source]#

Maps order of on based on the order specified in by.

Parameters:
  • on (list[T]) – List which order is to be mapped onto.

  • by (list[int]) – List which specifies the new order of on

Return type:

list[T]

>>> descending = [5, 4, 3, 2, 1, 0]
>>> ascending = list(range(10, 16))
>>> map_order(ascending, descending)
[15, 14, 13, 12, 11, 10]