a = [0, 3, 1, 10]
a.zip((0...a.length).to_a).sort { |x, y| x[0] <=> y[0] }