Use of Sort() function

What is the use of sort() function?
What is the meaning of arr+5 inside sort() ?
Can anyone of you please explain me in detail.

@Tiwary725
Hello Ravi,

  1. What is the use of sort() function?
    sort function is predefined function in stl library of c++.if we have array or vector and if we want to sort it in increasing ,decreasing or some other criteria then we can easily do it using sort function in just one line.
  2. What is the meaning of arr+5 inside sort() ?
    let say we have array of size 5
    arr[]={4,-1,2,3,10}
    and we want to sort it using sort function in increasing order then we do something as follows
    sort(arr,arr+5);
    here first argument (i.e arr) is base address of array.
    second argument (i.e arr+5) is address next to end element of array .here 5 is basically number of elements
  3. Can anyone of you please explain me in detail.
    checkout stl playlist of your course .you will find videos explaining its working and its various use cases

I hope you find this helpful

Sir I couldn’t understand the significance of arr+5 as an argument in the sort() function. please explain it again

sort(arr,arr+5) means that this function will sort starting five elements of the array leaving the remaining as unsorted.