What would be the best way to implement a qsort that does sort on multiple indexes. ex. first sort on primary index then secondary index.
Code://before sort: {(0, 3),(1, 2),(0, 1)} //after sort: {(0, 1),(0, 3),(1, 2)}
Thank you!Code:typedef struct{ boolean element1;//primary int element2;//secondary }foo int my_cmp(){ //?? what would be the most efficient implementation } int main(){ foo a[20]; //assume the array gets filled here qsort(&a[0], sizeof(a),sizeof(a[0]), my_cmp); return 0; }