I would like to sort a 2D array based on the similarity between elements compared to the element at index 0.
How is a custom sort function defined that can use the external 3rd object, the element at index 0?
The compare function needs to do the following
bool compare(float *a, float *b) {
float *source = 2DArray[0];
return distance(source, a) > distance(source, b);
}
when calling it
std::sort(std::begin(2DArray), std::end(2DArray), compare);
there is obviously no access to 2DArray.
How can this be written so that an object can call a function to call the sort function and give access to the 2DArray[0]?