I have Pairs that I would like to sort. I have already done the compare implementation and it seems to be working.
I also saw a solution online but the problem is that it doesn't allow it to be static.
public static ArrayList <Pair<Integer, Integer>> pairList = new ArrayList<Pair<Integer, Integer>>();
public static Pair<Integer, Integer> pair1 = new Pair<>(6, 7);
public static Pair<Integer, Integer> pair2 = new Pair<>(7, 7)
This is where I'm getting the Error Change compare() to static
with the solution that I'm testing out.
Method that I'm testing out:
public class MachineNoComparator implements Comparator <Pair<Integer, Integer>> {
public int compare(Pair<Integer, Integer> o1, Pair<Integer, Integer> o2) {
return o1.getMachineNo().compareTo(o2.getMachineNo());
}
}