def get_original_order_from_reordered_list(L, ordering):
  """ Returns the original order from a reordered list. """
  ret = [None] * len(ordering)
  for orig_idx, ordered_idx in enumerate(ordering):
    ret[ordered_idx] = L[orig_idx]
  return ret