Collections.reverseOrder() comparator does lexicographical sorting when used with a max heap toArray function.
Example: 4, 35, 41 would print as 41, 4, 35.
What I want is for it to print as 41, 35, 4
PriorityQueue<Integer> maxHeap = new PriorityQueue<>(Collections.reverseOrder());
maxHeap.add(4);
//Prints [4]
System.out.println("MaxHeap:"+ Arrays.toString(maxHeap.toArray()));
maxHeap.add(35);
//Prints [35, 4]
System.out.println("MaxHeap:"+ Arrays.toString(maxHeap.toArray()));
maxHeap.add(41);
//Prints [41, 4, 35]
System.out.println("MaxHeap:"+ Arrays.toString(maxHeap.toArray()));