Basically, I am trying to do Insertion Sorting on a tuple which is stored inside a vector, and I have a function to do it, when I only use the first value (get<0>(tupleVector[i])) it works, but when I try to add the second value (get<1>(tupleVector[i])) it doesn't, here's the whole function code.
void sort(vector<tuple<size_t, size_t>>& tupleVector, vector<int> idVector){
// insertionSort
for (int i = 1; i < tupleVector.size(); i++) {
int key = get<0>(tupleVector[i]);
int key2 = get<1>(tupleVector[i]);
int j = i;
while (j > 0 && get<0>(tupleVector[j - 1]) > key && get<1>(tupleVector[j - 1]) > key2) {
get<0>(tupleVector[j]) = get<0>(tupleVector[j - 1]);
get<1>(tupleVector[j]) = get<1>(tupleVector[j - 1]);
j--;
}
get<0>(tupleVector[j]) = key;
get<1>(tupleVector[j]) = key2;
}
cout << "Sorted" << endl;
}
EDIT:
I forgot to give examples of how it doesn't work, if I use values like ([500, 100], [700, 100], [100, 100], [500, 200]) it just doesn't sort anymore, but if I remove the (get<1>(tupleVector[i])) then it sorts based on the first value, but I need to sort for both, there's no compiler error or anything, it just doesn't sort