name of a sorting algorithm

Ulrich Eckhardt ulrich.eckhardt at dominolaser.com
Tue Feb 14 10:33:24 EST 2012


Am 14.02.2012 16:01, schrieb Jabba Laci:
> Could someone please tell me what the following sorting algorithm is called?
>
> Let an array contain the elements a_1, a_2, ..., a_N. Then:
>
> for i = 1 to N-1:
>      for j = i+1 to N:
>          if a_j<  a_i then swap(a_j, a_i)
>
> It's so simple that it's not mentioned anywhere.

Please do your own homework. This code isn't even Python!


> I guess it's called "selection sort" but I'm not sure.

You guessed right.


Uli



More information about the Python-list mailing list