Comparator function in sort inbuilt function

how does the sort inbuilt function work internally and when we add comaparator function as third arguement in sort function , how does it work again internally.

Algorithms used by sort()
The algorithm used by sort() is IntroSort. Introsort being a hybrid sorting algorithm uses three sorting algorithm to minimise the running time, Quicksort, Heapsort and Insertion Sort. Simply putting, it is the best sorting algorithm around. It is a hybrid sorting algorithm, which means that it uses more than one sorting algorithms as a routine.

When you use comparator function , it just ordered the selected elements according to the given comparator function. So, basically comparator function is nothing just giving a external functionality to sort function .
Hit like if u get it :slight_smile:

1 Like

Anubhav sir can you please explain IntroSort little more, using a complete example, and do a dry run on it please. :smiley:
Thank you :stuck_out_tongue:

jaa padh le…mid sem aa rahe h.
@tusharsk

Dislike hona chahiye tha portal pe :frowning:

Please help @Anubhav-Aron-1353657628083250 Sir!