I managed to do selection sort in ruby in one line:

a=[7,4,9,55,98,11,42]

a.each_index {|i| a.each_index {|i2| a[i], a[i2]=a[i2], a[i] if a[i]<a[i2]}}

Pretty elegant.

I think that selection sort is faster if inner loop goes from last to first 
element.
There is reverse_each but is there reverse_each_index or something ?