This content has been marked as final. Show 2 replies
I know that I can achieve a similar result by casting the List to an array and then doing a sort and then using addAll() to make it back into a list or I could just use a SortedList of some kind. e.g.
//perhaps an equivelant of a functional object added here in the constructor List<String> listStrings = new Vector<String>(); listStrings.add("Hello"); listStrings.add("Cruel"); listStrings.add("World"); sort(listStrings); for(String strString : listStrings) System.out.println(strString);
I was just windering if there was another method that would be cleaner than this. (A Sorted List of some kind would be very clean unless you wanted to sort the array at a later stage after using it in its unsorted form first, also what if you want duplicates?)
SortedSet<String> setStrings = new TreeSet<String>();