I have an ArrayList of version strings that I would like to sort so that the newest is the first listed.
ArrayList<String> items = new ArrayList<String>();
items.add("4.1.0");
items.add("4.1.1");
items.add("4.1");
items.add("5.1");
items.add("4.0.1");
My Expected Output is:
5.1
4.1.1
4.1.0
4.1
4.0.1
When considering the values as Integers, "4.0.1" is greater than "4.1", which is not true in the case of versions.
I am thinking of using a Comparator Interface for each major, minor and incremental version. Is there an easier way of doing this?