Final version of the comparator that will be used by priority queue