To sort a list, you should probably take the member function sort. See that example :
list::sort - C++ Reference[
^].
Generally, you won't use a
std::list
if you need sorting.
And if you are using a map, then the key is the field that need to be sorted. You should reconsider which containers you use and also select appropriate algorithms.