Selecting multiple elements with [

Sorting:

x <- c(5, 2, 3)
order(x)
## [1] 2 3 1
x[order(x)]
## [1] 2 3 5
sort(x)
## [1] 2 3 5

These also take an argument decreasing =.