Page 1 of 1

multi dim sorting problem

Posted: 27 Jan 2015, 22:44
by HaWe
hi,
I have a sorting problem to be resolved by highest possible speed.

I have BLOBS provided by a struc
struc {
int x
int y
int heigth
int width
char colorID} tblob;
and I have a various number of random

tblob blob[];

the max number of blobs is 1000 but actually it will probably not exceed 50.
colorID is sth between 0 and 15.


I get the blob data by a serial connection randomly, unsorted.

I want to sort by
1.) colorID
2.) size which is (width * heigth)

I want to access the blob data by searching for the coordinates by
blobcoordinates(colorID, sizeorder, &x, &y), e.g.

blobcoordinates(2, 3, &x, &y, &width, &height) will return by reference the x,y coordinates plus sizes of the 3rd largest object of colorID=2.

what do you think would be the quickest coding ?