Order List in java based on custom field value
Order List in java based on custom field value I have a list as follows: List<Data> list = new ArrayList<Data>() Data { String status; String type; } From some Service I am getting data as below: list = ["S","a"],["V","b"],["E","c"]; I need list to be ordered by status so that V,S,E so that I can pass it to filter for further processing: updatedlist = ["V","a"],["E","b"],["S","c"]; I got understanding using compareTo we can arrange in ascending/descending order as follows but I dont need this public int compare(Data d1, Data d2) { String status1= d1.getStatus(); String status2= d2.getStatus(); //ascending order return status1.compareTo(status2); //descending order //return status2.compareTo(status1); } Please suggest how can achieve the List status order as V ,E,S. ...
