name of a sorting algorithm

Arnaud Delobelle arnodel at
Tue Feb 14 17:22:45 CET 2012

On 14 February 2012 15:31, Dennis Lee Bieber <wlfraed at> wrote:
> On Tue, 14 Feb 2012 16:01:05 +0100, Jabba Laci <jabba.laci at>
> 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 = 1 to N-1:
>>    for j = i+1 to N:
>>        if a_j < a_i then swap(a_j, a_i)
>        Off hand... The ancient Bubble-Sort...


No, it's not Bubble Sort.  Bubble sort only swaps adjacent terms.

I don't know what this sort is called, if it even has a name.  It's a
kind of Selection Sort, as each pass it looks for the minimum of the
remaining unsorted items.  But it ruffles the unsorted list each pass,
seemingly to save using an extra register to store the current minumum
(there was a time when registers were at a premium).


More information about the Python-list mailing list