--0015174c1422fdf036046e753702
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

2009/7/11 Haris Bogdanovi <fbogdanovi / xnet.hr>

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


I'm sorry to disappoint you, but that is bubblesort, not selectionsort
See wikipedia for more information.

I think that selection sort is faster if inner loop goes from last to first
> element.


The bubblesort you did here will not be faster, no matter what order
you traverse the items in. After all, you will look at each item in the
outer loop and again at each item in the inner loop again.
That makes it n-squared no matter what order you traverse them in.

There is reverse_each but is there reverse_each_index or something ?


Not that I know of, but you could just do

[1,2,3,4].reverse.each_with_index

But I still don't get what you're trying to achieve here...?

Greetz!

--0015174c1422fdf036046e753702--