It returns the order of each element in x
, (not as some think the elements of x
ordered). When there are two identical elements in the first argument to order
(x
in your example above ) ties are broken by further arguments to order
(y
and z
in your order
example). This visual example, showing the order returned will hopefully explain it in fewer words...
cbind(x[ii],y[ii],z[ii])
# [,1] [,2] [,3]
# [1,] 1 5 5 |===> 4 values of 1 in x, first value is selected by lowest value (5) in y
# [2,] 1 6 4 |
# [3,] 1 9 1 |:==> both have 9 in y, tie is broken by 1 in z
# [4,] 1 9 2 |:==> value of 2 in z
# [5,] 2 4 6
# [6,] 2 7 3
# [7,] 3 1 9
# [8,] 3 3 7
# [9,] 3 8 2
#[10,] 4 2 8