I'm trying to sort a collection of loans where the statuses of loans are Active, Rejected, Pending and Approved.Active loans should get the highest priority and the others in any order.I implemented the Comparator interface's compare().
here 's the implementation of compare()
@Override
public int compare(Object o1, Object o2) {
LoanAccountData loanAccountData1 = (LoanAccountData) o1;
LoanAccountData loanAccountData2 = (LoanAccountData) o2;
if (loanAccountData1.getStatusStringValue().equals("Active")) {
return -1;
} else {
return 1;
}
}