Gnome Sort in Redcode
2
An implementation of Gnome Sort in 9 lines of Redcode. Smaller and faster than Bubble Sort.
; x elements sorted in min (2x-1), max (5x^2-6x+2) cycles
org loop
p mov temp, FIRST+LENGTH-1
seq l, #LENGTH-1
nop >l, >p
loop slt @p, <p
l djn loop, #LENGTH-1
jmz go+1, l
mov >p, temp
mov @p, <p
go jmp p, >p






There are currently no comments for this snippet.