- If the value at the end is smaller than the value at the start, swap them.
- If there are 3 or more elements in the current list subset,
- Stooge sort the initial 2/3 of the list
- Stooge sort the final 2/3 of the list
- Stooge sort the initial 2/3 of the list again

Implementation in Redcode:

org inner

stack equ outer-2

temp equ outer-1

outer mov p, <stack

sub.ba temp, @stack

mov p, <stack

add.b temp, @stack

sub.ba temp, p

inner slt {p, @p

jmp noexch, }p

mov @p, temp

p mov FIRST+LENGTH, FIRST

mov temp, }p

noexch mov.ab p, temp

sub.b p, temp

div #3, temp

jmn outer, temp

finished mov.f >stack, p

jmn inner, p