Hi I have a C++ code where there is a struct and list of structs. In my struct, the first element is a string. In list of struct, how do I sort with the first element of the structure so that after sorting all the elements in the list will be arranged alphabetically? please find piece of sample code below. thanks in advance.
struct samplestruct
{
string Name;
int Number
};
samplestruct obj_samplestruct;
vector<samplestruct> List;
obj_samplestruct.Name = "Tom";
obj_samplestruct.Number = 1;
list.push_back(obj_samplestruct);
obj_samplestruct.Name = "Jerry";
obj_samplestruct.Number = 2;
list.push_back(obj_samplestruct);
obj_samplestruct.Name = "Tom";
obj_samplestruct.Number = 3;
list.push_back(obj_samplestruct);
Now in the above code how do I sort as per Name in structure so that in list the members should be arranged alphabatically..