Ruby なら、この順番

a = [1, 2, 3]
a.permutation(2).to_a

#=> [ [1,2],[1,3],[2,1],[2,3],[3,1],[3,2] ]