[try Beta version]
Not logged in

 
Sort two arrays together

Jun 19, 2014 at 4:53pm
I am trying to using two arrays, one to store name and another to store persons age. I have the arrays created and have been able to get the data in and display a table. However, I can't figure out how if I sort the age array, I can get the name array to follow suit. The name array is declared as a string and the age array is declared as an int. I am extremely new to C++ and programming in general and any assistance would be greatly appreciated.
Jun 19, 2014 at 5:21pm
I think it would be better if you use an object where you store a name and a person age belonging to that name together. Then you can sort those objects stored in an array. Each object keeps the person age and the corresponding name together, so there is no problem with sorting both at the same time.

For declaring and using objects:

http://www.cplusplus.com/doc/tutorial/classes/
Topic archived. No new replies allowed.