sort.list(x, partial=NULL, na.last=T)
x for partial sorting.
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.
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.
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.
# 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