Selection sort is an O(n²) algorithm. The redcode implemention is 10 instructions long and requires 1.5n²+5.5n-8 cycles in the worst case, making it approximately twice as fast as Bubble Sort.

Implementation in Redcode:

org outer+1

temp equ (outer-1)

outer mov.b x, y

mov <p, temp

p mov.ba #FIRST+LENGTH-1,#FIRST+LENGTH

inner slt <p, *p

mov.ba p, p

y djn inner, #LENGTH-1

add.b x, p

mov *p, @p

mov temp, *p

x djn outer, #LENGTH-1