binius_utils::sorting

Function unsort

source
pub fn unsort<T>(
    original_indices: impl IntoIterator<Item = usize>,
    sorted_objs: impl IntoIterator<Item = T>,
) -> Vec<T>
Expand description

Restores the original order of a collection of objects based on their original indices.

This function takes a collection of objects and their corresponding original indices, and returns a vector of the objects sorted back to their original order.

§Arguments

  • original_indices: An iterable collection of the original indices of the objects.
  • sorted_objs: An iterable collection of the objects that have been sorted.

§Returns

A vector of objects restored to their original order based on the provided indices.

§Note

This function assumes that the length of original_indices and sorted_objs are the same, and that original_indices contains unique values representing valid indices.