help, please, with sorting of the simply linked list. There is a student structure, the format is surname_name_of_the_property. need to do a sort by last name. below I will attach my unsuccessful attempt, the structure itself and a small piece of the program.
struct student { string name; string surname; string middlename; float progress; int age; struct student* next; }; struct list { student st; list *next; }; void Print(list *b) { list *print = b; while (print != NULL) { std::cout << print->st.surname << " " << print->st.name << " " << print->st.middlename << " " << print->st.age << " " << print->st.progress << endl; print = print->next; } std::cout << "NULL\n"; } void sort(list **begin) { list *t = new list; list *t2 = *begin; t = *begin; while (t != 0) { list *t1 = t->next; if (t1->st.surname < t2->st.surname) { list *tmp = t2; t2 = t1; t = t2; } t = t->next; } } int main() { setlocale(LC_ALL, "Russian"); SetConsoleCP(1251); SetConsoleOutputCP(1251); forward_list <student> st; list* begin = NULL; list* head = nullptr; list* item = nullptr; for (;;) { int x = menu(); switch (x) { case 1: { Print(begin); break; } case 8: { sort(&begin); break; }