Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Returns a sorted version of the given vector. If no second argument is given, the result will be sorted in ascending order; otherwise, a second argument consisting of a string can be given: '<' for ascending, '>' for descending order.

 

Excerpt
vector sort_indices( vector )
vector sort_indices( vector,string )

Performs the same sorting as the sort() function, but instead of returning the sorted values, it returns the indices ofwhere the sorted values lie in the original vector. For example:

v1 = |5, 3, 4, 9, 1, 4.2|
sort(v1)                  # returns |1, 3, 4, 4.2, 5, 9|
sort_indices(v1)          # returns |5, 2, 3, 6, 1, 4|, e.g. the 4th sorted number is the 6th element from the original


Excerpt
vector sqrt( vector )

Returns the vector of the square root of the input vector at each element. Missing values are retained, unaltered by the calculation.

...