I\'m running an example to understand the behavior of Comparator in Java.
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparat
It depends on sorting algorithm, on how many times it calls compare method. Once we call Collections.sort() method, it goes to the implementation of sorting used in Collections.sort().
Collections.sort() implementation uses merge sort. According to the Javadoc, only primitive arrays are sorted using Quicksort. Object arrays are sorted with a Mergesort as well.