You need to tell
sort
how to compare the two structs. since there's no default comparison for non basic types. Do you want to sort by name or by grade, or by grade then by name, or ...?
Probably the easiest way is to add an operator< method to the struct:
struct StudentDataTypes
{
std::string name{};
int grade{};
bool operator<(const struct StudentDataTypes& other) const
{
return name < other.name;
}
};
see further details here:
std::sort - cppreference.com[
^]