Checkmark on Circle.png

Gnomesort/Python

Aus KGS-Wiki
A = [19,84,650,13,47,65,10,6,50,16,58,70,56,10]

n = len(A)
i = 0
while not i == n-1:
    if A[i] <= A[i+1]:
        i = i + 1
    else:
        a1 = A[i]
        a2 = A[i+1]
        A[i] = a2
        A[i+1] = a1
        if i > 0:
            i = i - 1
            
print(A)