How to sort alphabetically while ignoring case sensitive?
It is very unclear what you are trying to do, but you can sort a list like this:
List<String> fruits = new ArrayList<String>(7);
fruits.add("Pineapple");
fruits.add("apple");
fruits.add("apricot");
fruits.add("Banana");
fruits.add("mango");
fruits.add("melon");
fruits.add("peach");
System.out.println("Unsorted: " + fruits);
Collections.sort(fruits, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
return o1.compareToIgnoreCase(o2);
}
});
System.out.println("Sorted: " + fruits);
Collections.sort(listToSort, String.CASE_INSENSITIVE_ORDER);