I need a Collection
that sorts the element, but does not removes the duplicates.
I have gone for a TreeSet
, since TreeSet
actu
Add the elements to the arraylist and then sort the elements using utility Collections.sort,. then implement comparable and write your own compareTo method according to your key.
wont remove duplicates as well, can be sorted also:
List<Integer> list = new ArrayList<>();
Collections.sort(list,new Comparator<Integer>()
{
@Override
public int compare(Objectleft, Object right) {
**your logic**
return '';
}
}
)
;