I have a priority queue that contains Patients which look like this:
patientQueue.add(new Patient(idNr, name, emergencyNr));
Now I want to sort the Queue first by emergencyNr and then idNr. The `name´ doesn´t matter.
Right now I can sort the priority queue with comparable implemented in patient:
@Override
public int compareTo(Patient otherRequest) {
return Integer.compare(isEmergencyCase(), otherRequest.isEmergencyCase());
}
How can I implement an method that also sorts by IdNr? So if all EmergencyNr is equals then the lowest idNr will be first.
Thanks in advance guys!