Skip to content

Files

21 lines (14 loc) · 441 Bytes

sort.md

File metadata and controls

21 lines (14 loc) · 441 Bytes

sort

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 << " "; 
    }

Run Code