Comparator or Compare function

I am not able to understand how comparator works in sorting algorithm