c++ - How to sort two arrays based on the first array -


i have 2 arrays, 1 points , holding names. want sort array points in ascending order , name array go along corresponding point array. wondering how that. here's i've tried far

string sname[nos]; char sex[nos];           //variable hold sex information of students char gpa[nos];           //variable hold gpa char essaygrade[nos]; int convgpa[nos]; int convessaygrade[nos]; double overallpoint[nos]; pair<double, string> pairs[nos]; int want_len = nos;    pairs[i] = make_pair(overallpoint[i], sname[i]);                     cout << endl <<"over point of " << pairs[i].second << ": " << pairs[i].first << endl;                     sort(pairs.begin(), pairs.end()); 

all necessary variables have been initialized.

if got right, can use (map) :

     #include<map>       using namesapce std;         map<double, string> mymap;         mymap.insert(name of pair want insert) 

std::map sorts self automaticaly


Comments