sortby
Sort an array by one or more reference arrays.
Syntax
Section titled “Syntax”v = sortby(arr, by_array1, sort_order1, by_array2, sort_order2, ...)Description
Section titled “Description”Sorts arr by the values in by_array1 (and ties broken by by_array2, etc.). Each by_array_n must be the same shape as arr. Each sort_order_n is 1 (asc) or -1 (desc).
Example
Section titled “Example”sortby([10 20 30 40], [3 1 4 2]) % [20 40 10 30]