REORDER

Purpose:

Arranges a series or table based on a list of indices.

Syntax:

REORDER(series, indices)

series

-

Any series or multi-column table.

indices

-

Series of indices (i.e. sample numbers) on which to reorder.

Returns:

A series or table.

Example:

reorder(W1, grade(W1))

 

returns a the same result as sort(W1).

Example:

W1: {2, 5, 9, 1, 3}

W2: reorder(W1, {3, 1, 2, 4, 5})

 

W2 contains the series {9, 2, 5, 1, 3}. The same result can be achieved with array addressing:

 

W3: W1[{3, 1, 2, 4, 5}]

Example:

To reorder a table based upon the values in the first column:

 

W1: {{2, 5, 3},

     {1, 1, 1}, 

     {4, -1, 0}} 

 

reorder(W1, grade(col(W1, 1), 1))

 

returns the array:

 

{{1, 1, 1}, 

 {2, 5, 3}, 

 {4, -1, 0}} 

 

This is equivalent to:

 

W1[grade(col(w1, 1), 1), ..]

 

or

 

W1[grade(W1[.., 1], 1), ..]

Remarks:

REORDER is similar to LOOKUP but much faster on larger series.

 

The results produced by REORDER can also be achieved by array addressing. See .. (Range Specifier) for more details on array addressing.

See Also:

.. (Range Specifier)

GRADE

LOOKUP

SORT