How can I sort a RGB struct vector v[i].R,v[i].G,v[i].B
in C++ in order to later do a binary search on it to find the closest value for another image using the formula dist = abs(v[i].R-img.R)+abs(v[i].G-img.G)+abs(v[i].B-img.B)
.
I managed to do this for grayscale images given that for an image there is only one value but I can't figure out how to do it when there are 3 RGB values. More precisely, what should be the criteria for sorting the vector to get an accurate result? Many thanks.