// compare duedate and priority and ??duration?? public int compareTo(Task other) { if (duedate.compareTo(other.getDueDate()) != 0) { return duedate.compareTo(other.getDueDate()); } else if (priority != other.getPriority()) { return (int) (other.getPriority() - priority); } else { return (int) (other.getDuration() - duration); } }
// Overriding the compare method to sort the dueDate public int compare(Task t1, Task t2) { int result = 1; Date d1 = t1.getDueDate(); Date d2 = t2.getDueDate(); if (d1 != null & d2 != null) { result = t1.getDueDate().compareTo(t2.getDueDate()); } else if (d1 == null) { result = -1; } return result; }