arg_sort()

Returns a list of indices that would sort a given list.

Synopsis

arg_sort(list-expression)

Description

This function determines how to sort the given list, and then returns the list of indices that should be used to sort the list. Note that list indices in FRED are 0-based, in that \(0\) refers to the first item in the list.

Parameters

list-expression

An expression that evaluates to a list.

Returns

A list of indices that would sort the the given list.

Examples

The following example returns the list [3, 2, 0, 1], corresponding to the indices to use when sorting the list [8, 9, 10, 11].

arg_sort([10,11,9,8])

See Also

filter_by_index(), filter_values(), find_index(), index_agents(), index_values(), shuffle(), sort()