How is the bool statement working in the code ?
CPP-Strings STL
@Riankk Here bool statement is used to create a custom comparator . The inbuilt sort function without any comparator will sort elements in ascending order. Whenever you need to sort the elements in different ways according to you choice, you need to create a custom comparator.
say comparator fn is:
bool compare( string a, string b ){
return a>b;
}
sort(arr,arr+n,compare)–> This will swap two elements of the array in order that they are arranged in descending order ie. reverse dictionary order.