4.5 Sorting functions
Sorting can be used to sort values or the indices of those values in
either ascending or descending order. For example, if v
is declared
as a real array of size 3, with values v=(1,−10.3,20.987), then the various sort routines produce sort_asc(v)=(−10.3,1,20.987)sort_desc(v)=(20.987,1,−10.3)sort_indices_asc(v)=(2,1,3)sort\_indices\_desc(v)=(3,1,2)
real[]
sort_asc
(real[] v)
Sort the elements of v in ascending order
int[]
sort_asc
(int[] v)
Sort the elements of v in ascending order
real[]
sort_desc
(real[] v)
Sort the elements of v in descending order
int[]
sort_desc
(int[] v)
Sort the elements of v in descending order
int[]
sort_indices_asc
(real[] v)
Return an array of indices between 1 and the size of v, sorted to
index v in ascending order.
int[]
sort_indices_asc
(int[] v)
Return an array of indices between 1 and the size of v, sorted to
index v in ascending order.
int[]
sort_indices_desc
(real[] v)
Return an array of indices between 1 and the size of v, sorted to
index v in descending order.
int[]
sort_indices_desc
(int[] v)
Return an array of indices between 1 and the size of v, sorted to
index v in descending order.
int
rank
(real[] v, int s)
Number of components of v less than v[s]
int
rank
(int[] v, int s)
Number of components of v less than v[s]