How to convert a Collection to List?
I believe you can write it as such:
coll.stream().collect(Collectors.toList())
I think Paul Tomblin's answer may be wasteful in case coll is already a list, because it will create a new list and copy all elements. If coll contains many elemeents, this may take a long time.
My suggestion is:
List list;
if (coll instanceof List)
list = (List)coll;
else
list = new ArrayList(coll);
Collections.sort(list);
Something like this should work, calling the ArrayList constructor that takes a Collection:
List theList = new ArrayList(coll);
List list = new ArrayList(coll);
Collections.sort(list);
As Erel Segal Halevi says below, if coll is already a list, you can skip step one. But that would depend on the internals of TreeBidiMap.
List list;
if (coll instanceof List)
list = (List)coll;
else
list = new ArrayList(coll);