Java Array Sorting

Submitted by code_admin on Fri, 07/20/2018 - 13:00

Sory List by Comparator

  1. Collections.sort(excludedPrefixes, new Comparator<String>() {
  2.     public int compare(String o1, String o2) {
  3.         return o1.compareToIgnoreCase(o2);
  4.     }
  5. });

Sort a Map

Just get a list from the values of the map and sort that as above

  1. List<String> excludedPrefixes = new ArrayList<String>(excludedPrefixesMap.values());

Google Juice

Hash HashMap List ArrayList


RJM Article Type
Quick Reference