Doubt regarding sort function & comparator

in earlier videos and in this video
we were not taught about sort function and what parameter it takes and what output we get and its directly used in this video so…explain it plz

we were not taught comparator/bool function that was used in this video…so explain that too

Basically, sort function is used in c++, to sort the elements, defined under header file algorithm.h
The advantage is that you need not use any of the sorting algorithm to sort the elements, instead this function used the sorting algorithm which takes N Log N complexity to sort the elements.
It can be written as
sort(ar,ar+n)
or
sort(ar,ar+n,mycompare)
And then u can write your mycompare function of your own choice

whats use of mycomparator function?
to arrange them in order other than lexicographically(default)???

By default when we sort using sort function, it gives elements arranged in ascending order, but we can write mycompare function to change the functionality of sort function