I have some parallel vectors that need to be sorted. With my knowledge I set them up to be sorted such as this:
Code:
void sortInventory(vector<int>& itemID, vector<string>& itemName, vector<int>& pOrdered, vector<double>& manufPrice, vector<double>& sellingPrice)
{
int i, j;
int min;
for (i = 0; i < itemID.size()-1; i++)
{
min = i;
for (j = i + 1; j < noOfRows; j++)
if (itemName[j] < itemName[min])
min = j;
itemName[i].swap(itemName[min]);
itemID[i].swap(itemID[min]);
pOrdered[i].swap(pOrdered[min]);
manufPrice[i].swap(manufPrice[min]);
sellingPrice[i].swap(sellingPrice[min]);
}
}
Well, since I've only covered arrays, I setup as above using swap. As you guys know there is no swap in vectors. Can anybody give me a hint as to what to look for? I know there is a sort function but I need to sort the vectors in parallel.