sort function of vector code example Example 1: sort vector sort(v.begin(), v.end()); Example 2: how to sort a vector vector v; sort(v.begin(),v.end());