Javatpoint Logo
Javatpoint Logo

C++ List sort()

C++ List sort() function arranges the elements of a given list in an increasing order. It does not involve in any construction and destruction of elements. Elements are only moved within the container.

Syntax

Parameter

It does not contain any parameter.

Return value

It does not return any value.

Example 1

Let's see a simple example

Output:

Elements of list are : 6,4,10,2,4,1,
Sorted elements are : 1,2,4,4,6,10

In this example, sort() function sorts the elements of a given list and its output is 1,2,4,4,6,10.

Example 2

Let's see a simple example

Output:

javaTpoint
Taaijnoptv

In this example, sort() function sorts the character values on the basis of their ascii values.


Next Topicmerge() Function



Please Share

facebook twitter google plus pinterest