name of a sorting algorithm
mwilson at the-wire.com
Tue Feb 14 10:25:16 EST 2012
Jabba Laci wrote:
> Could someone please tell me what the following sorting algorithm is
> 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 ,
the least of the remaining elements in , etc.
More information about the Python-list