Image for post
Image for post

A Comparator function is nothing else but a function which we define to compare two objects. The data-type of these objects can be user-defined or it can be primitive.

Suppose we have to sort a vector in descending order. The code goes as follows.

Rohit Kumar

Software Developer at Samsung.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store