Vector of Indices that Sort Data

DESCRIPTION:

Returns a vector of integers giving the order of the data or position of the data (if it is a series or bdSeries object)

USAGE:

sort.list(x, partial=NULL, na.last=T) 

REQUIRED ARGUMENTS:

x
a vector or a series or a bdSeries object. Missing values are allowed. If the vector is numeric, then infinite values are also allowed.

OPTIONAL ARGUMENTS:

partial
vector of indices (in ascending order) into x for partial sorting.
na.last
a vector of length 1. If TRUE, then missing values ( NAs) are placed after all other values. If FALSE, NAs are placed first. When na.last=NA, then NAs are discarded. An error occurs if na.last is of mode "character" and there are NAs in x.

VALUE:

vector containing a permutation of the indices of x that would sort it into ascending order. The first element gives the index of the element of x that is first in the sort of x, etc. If x is a series or bdSeries object, it will be a vector of the indices of the position of the data in ascending order, i.e. the first element gives the index of the element of x that has the smallest position, etc. This vector may be shorter than x if na.last=NA, but is always the same length otherwise.

DETAILS:

If partial has positive length, it should contain strictly ascending indices into x, in which case only the permutation elements named in partial will be guaranteed to be correct after the call to sort.list. Other permutation elements will sort x into the right gaps between the partial elements, but not necessarily correctly within the gaps.

If x is complex, the real parts are sorted with the imaginary parts breaking ties.

To sort a series or a bdSeries object x by selected data columns, use order or rank.

SEE ALSO:

, which does the job of on more than one object. , , , .

EXAMPLES:

# sort a matrix according to its 1st column 
mat[ sort.list(mat[,1]), ] 
sort.list(xvec, na.last="") # cause an error if missing values are present