Skip to content

reorder

string  reorder(string value, int indices[])

Returns a reordered version of the characters (not bytes) in the UTF-8 string value according to the positions in indices. The result is a UTF-8 encoded string.

<type>[] reorder(<type>values[], int indices[])

Returns a reordered version of the items in values according to the positions in indices.

This usually uses a list of indices generated by argsort. See the argsort page for an example.

  • Negative numbers in the index list will read from the end of the array.
  • The length of the resulting array/string is the same as the length of the indices.
  • Out of bound values will insert zeros, but this should be considered an error.