That's great, thanks for the tip. Now I just need to work out how to use the qsort function. Any ideas how to include the 'compare' argument (the code below is the sort code from stdio.h)?

void qsort(
void *base, // array to be sorted
int num, // number of elements
int width, // element size
void* compare //int (__cdecl *compare)(void* element1,void* element2)

Also, I am having a go at the sortData function you mentioned above. I'm pretty sure I can achieve what I want to achieve, but no doubt my code will be highly inefficient. I'll post it once I'm done and would really appreciate any critiques.

Cheers