Built In Sorting?

BlitzMax Forums/BlitzMax Beginners Area/Built In Sorting?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Looking at the source (blitz_array.c):

#define SWAP(X,Y) {t=*(X);*(X)=*(Y);*(Y)=t;}
#define QSORTARRAY( TYPE,IDENT )\
static void IDENT( TYPE *lo,TYPE *hi ){\
	TYPE t;\
	TYPE *i;\
	TYPE *x;\
	TYPE *y;\
	if( hi<=lo ) return;\
	if( lo+1==hi ){\
		if( LESSTHAN(hi,lo) ) SWAP(lo,hi);\
		return;\
	}\
	i=(hi-lo)/2+lo;\
	if( LESSTHAN(i,lo) ) SWAP(i,lo);\
	if( LESSTHAN(hi,i) ){\
		SWAP(i,hi);\
		if( LESSTHAN(i,lo) ) SWAP(i,lo);\
	}\
	x=lo+1;\
	y=hi-1;\
	do{\
		while( LESSTHAN(x,i) ) ++x;\
		while( LESSTHAN(i,y) ) --y;\
		if( x>y ) break;\
		if( x<y ){\
			SWAP(x,y);\
			if( i==x ) i=y;\
			else if( i==y ) i=x;\
		}\
		++x;\
		--y;\
	}while( x<=y );\
	IDENT(lo,y);\
	IDENT(x,hi);\
}


Pretty basic quicksort..