i want so sort names by their ages
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
struct Person{
 std::string name;
 int age;
};
struct by_age{
  bool operator() (Person  const &a,Person const &b){
   return a.age>b.age;    
  }
};
int main(){
 vector<Person>people;
  for (int i=0;i<4;i++){
   cin>>people[i].age>>people[i].name;
  }
  sort(people.begin(),people.end(),by_age());
   for (int i=0;i<4;i++){
    cout<<people[i].name<<people[i].age<<" ";
   }    
 return 0;
}
but this code has many bugs please help look at this site
C++ STL: Custom sorting one vector based on contents of another