Why pair of string have used in the program of the sort the strings.
There may be more than 2 strings also. So why pair is used ??
Please explain ?
Splving a strings
And in case of reversal can we applt reverse function
hi, do you remember how we solve bubble sort?
we compare every adjacent pair, and decide to swap or not , to arrange the elements in the order we want.
at a time we only compare two elements. right?
same way sort() function works. it calls your function compare() by passing it a pair, and decides the order between these two objects. it calls this function for every possible pair, so that the order can be decided for any number of objects.
thanks