using this version of std :: sort
template <class RandomAccessIterator, class Compare>
void sort( RandomAccessIterator first, RandomAccessIterator last, Compare comp );
You can sort all the fields you want by supplying your own comparator. For instance,
struct CompareSalary
{
bool operator () ( const Employee& a, const Employee& b ) const
{
return a.salary < b.salary;
}
}
, std:: sort , , std::vector .