algorithm stoogesort(array L, i = 0, j = length(L)-1)
if L[j] < L[i] then
L[i] ↔ L[j]
if j - i > 1 then
t = (j - i + 1)/3
stoogesort(L, i , j-t)
stoogesort(L, i+t, j )
stoogesort(L, i , j-t)
return L
void stoogesort(int *item, int left,int right)
{
register int tmp, k;
if(item[left]>item[right])
{
tmp=item[left];
item[left]=item[right];
item[right]=tmp;
}
if((left+1)>=right)
return;
k=(int)((right-left+1)/3);
stoogesort(item,left, right-k);
stoogesort(item, left+k, right);
stoogesort(item, left, right-k);
}