SQL
SELECT x, y
FROM table_1
ORDER BY x, y DESC
R
order(X, na.last=TRUE, decreasing=FALSE)
返回值: X排好序的下标向量
na.last 控制空值NA排在最前还是最后,默认最后
desceasing 控制升序还是降序排列
例子:
> #vector
> X <- c(7,4,5,2,8,1,9,3) > order(X)
[1] 6 4 8 2 3 1 5 7