If a is the array, I want a.index(a.max), but something more Ruby-like. It should be obvious, but I\'m having trouble finding the answer at so and
a
a.index(a.max)
Here is a way to get all the index values of the max values if more than one.
Given:
> a => [1, 2, 3, 4, 5, 6, 7, 9, 9, 2, 3]
You can find the index of all the max values (or any given value) by:
> a.each_with_index.select {|e, i| e==a.max}.map &:last => [7, 8]