The standard way is to use std::sort
:
#include <algorithm>
// ...
std::sort(sname, sname + StudentNum);
std::sort
uses operator<
by default, which actually does an alphabetical comparison for strings.
EDIT: Indeed, it should be StudentNum
instead of 25.