.tHE .sIRIUS .cYBERNETICS .cORPORATION
Well, this is a very small sorting routine I once discovered in a newsgroup, called Comb-Sort.
It's quite small in size and also quite fast, altough I really can't say why. It's basically a kind of bubble-sort with variable gap-size.
In some quick tests with GfA-Basic I discovered that it's nearly as fast as quicksort, but the advantages are obvious:
mulu #65536*10/13,D0   swap D0 | « instead of » |
mulu #10,D0 divu #13,D0 |
gap = arraysize | ||
;the list is sorted if gapsize=1 and no swap occured while gap>1 or switchflag==true: | ||
gap = gap * 10 / 13 ;resize gap
if gap < 1: ;gap must be at least one
gap = 1
| ||
if gap==9 or gap==10: ;take advantage of little speedup
gap=11
| ||
switchflag = false ;no swap so far
| ||
for g = 1 to arraysize-gap:
| ||
if array[g]>array[g+gap]: ;in wrong order?
| ||
helper=array[g] ;yes, so swap them
array[g]=array[g+gap]
array[g+gap]=helper
switchflag=true ;remember that we swapped
|
bresenham
fast interpolation
chunky2planar
codeTips
.tSCc.
|
|