name of a sorting algorithm
Mel Wilson
mwilson at the-wire.com
Tue Feb 14 16:25:16 CET 2012
Jabba Laci wrote:
> 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 in xrange (N-1):
for j in xrange (i, N):
if a[j] < a[i]:
a[i], a[j] = a[j], a[i]
>
> It's so simple that it's not mentioned anywhere. I guess it's called
> "selection sort" but I'm not sure. The minimum selection sort is an
> improvement of this one.
It's what Wikipedia says a selection sort is: put the least element in [0],
the least of the remaining elements in [1], etc.
Mel.
More information about the Python-list
mailing list