bool comesBefore(const Student* student1, const Student* student2) { const char* s1 = student1->name; const char* s2 = student2->name; int i = 0; while (s1[i] == s2[i] && s1[i] != 0 && s2[i] != 0) { i++; } // If both strings are the same, compare the ages if (s1[i] == '\0' && s2[i] == '\0') { return (student1->age < student2->age) ? true : false; } return s1[i] < s2[i] ? true : false; }