Description : sort() function is used to sort the elements of the container by changing their positions.
Example :
// list declaration of integer type
std::list<int> mylist{ 1, 5, 3, 2, 4 };
// sort function
mylist.sort();
// printing the list after sort
for (auto value : mylist) {
std::cout << value << " ";
}