Custom Comparator For Sort

We can can customise our sort comparator as following:

from functools import cmp_to_key

class App:
    def comparator(self, intervalA, intervalB):
        if (intervalAshouldGoFirst): 
            return -1
        if (intervalBShouldGoFirst):
            return 1
        
    def something(self, intervals: List[List[int]]):
        intervals.sort(key = cmp_to_key(self.comparator))