i am having problems sorting data...i dont know to to go about it here is my code that i dont knw how to sort
<code>
#include <iostream>
#include <string>
using namespace std;
int main ()
{
int i;
struct person
{
string name;
int age;
};
person NAME[10];
for(i=0;i<10;i++)
{
cout <<"list of players and their ages";
cout <<"Enter the name and age of the person"<<endl;
cout <<"Name:";
cin >>NAME[i].name;
cout <<"Age:";
cin >> NAME[i].age;
}
for(i=0;i<10;i++)
{
cout <<NAME[i].name<<"::"<<NAME[i].age<<"years"<<endl;
}
return 0;
}
</code>
i want to sort it out so that it can output names and ages in ascending order.
// sort by name
sort( people, people + number_of_people, person_compare_names );
// sort by age
sort( people, people + number_of_people, person_compare_ages );
// First, sort by name
sort( people, people + number_of_people, person_compare_names );
// Next, stable sort by age
stable_sort( people, people + number_of_people, person_compare_ages );