The slowness of the recursion is not surprising, DBC must memorize variables (internal) local whenever the function is called itself.

If you are only 3 variables to sort, you can make an optimization, like this:

rem
sync on
sync
wait 2000
a=2
b=1
c=3
time = timer()
for i = 1 to 1000000
sorttemp(a,b,c)
next i
print "Temp Swap: ";timer()-time
time = timer()
for i = 1 to 1000000
sortnotemp(a,b,c)
next i
print "No-temp Swap: ";timer()-time
time = timer()
for i = 1 to 1000000
sortrecur(a,b,c)
next i
print "Recursion: ";timer()-time
time = timer()
for i = 1 to 1000000
silverman_sort(a,b,c)
next i
print "silverman sort: ";timer()-time
end
function sorttemp(a,b,c)
if a>c then t=a : a=c : b=t
if a>b then t=a : a=b : b=t
if b>c then t=b : b=c : c=t
endfunction
function sortnotemp(a,b,c)
if a>c then a=a+c : c=a-c : a=a-c
if a>b then a=a+b : b=a-b : a=a-b
if b>c then b=b+c : c=b-c : b=b-c
endfunction
function sortrecur(a,b,c)
if a > c then sortrecur(c,b,a) : exitfunction
if a > b then sortrecur(b,a,c) : exitfunction
if b > c then sortrecur(a,c,b) : exitfunction
endfunction
function silverman_sort(a,b,c)
if a>=c
if a>=b
if b>=c
`swap(a,c)
tmp=a : a=c : c=tmp
else
`swap(a,b):swap(b,c)
tmp=a : a=b : b=c : c=tmp
endif
else
`swap(c,b):swap(b,a)
tmp=c : c=b : b=a : a=tmp
endif
else
if a>=b
`swap(a,b)
tmp=a : a=b : b=tmp
else
if b>=c
`swap(b,c)
tmp=b : b=c : c=tmp
else
`nothing
endif
endif
endif
` print a;b;c
endfunction

DirectX 9.0c (February 2010)/ DBClassic v1.20