order() and sort()

  • order() can return rankings
order(order(x))
## [1] 1 2 3 5 4
# vs.
rank(x, ties = "random")
## [1] 1 2 3 5 4