I am trying to sort two sets of data, that are either in a 2d array or parallel arrays, either way it makes no difference but I cant seem to figure it out. Here are the two arrays:
/////way one///
int id[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int numDetected[10] = {40, 21, 2, 19, 45, 32,43, 90, 100, 8};
or
int 2dArray[2][10];
it makes no difference, but I cant seem to figure this out.
I want to order the arrays into a new array, (whether it is a 2d array or parrellel arrays) by the numDetected amount. So the largest numDetected is at element zero and the smallest at the end. But while doing that, I want to keep the id associated with that in the same element as the numDetected. So if numDetected[2] is the largest, I want numDetected[2] and id[2] to be the first elements in the new arrays.
Can anyone help me out?
struct item { int id; int numDetected; }and a container of those structs? And preferablyoperator<for that struct? That would make it a lot easier.