Lo más simple es que definas el operador "<" en tu struct y utilices el método sort de la clase list:
Código C++:
Ver original#include <iostream>
#include <string>
#include <list>
using namespace std;
struct Movie{
string name;
Movie(const string& _name): name(_name){}
bool operator<(const Movie& m){
return name < m.name;
}
};
int main(){
list<Movie> movies;
movies.push_back(Movie("cMovie"));
movies.push_back(Movie("aMovie"));
movies.push_back(Movie("gMovie"));
movies.push_back(Movie("bMovie"));
movies.sort();
for(list<Movie>::iterator it = movies.begin(); it != movies.end(); it++){
cout << it->name << endl;
}
return 0;
}