public static void sortStrings(String[] strings) {
        HashMap<String, ArrayList<String>> map = new HashMap<String, ArrayList<String>>();
        for (String s: strings) {
            char[] chars = s.toCharArray();
            Arrays.sort(chars);
            String key = String.valueOf(chars);
            if (!map.containsKey(key)) {
                map.put(key, new ArrayList<String>());
            }
            map.get(key).add(s);
        }
        int i = 0;
        for (String key : map.keySet()) {
            for (String s : map.get(key)) {
                strings[i++] = s;
            }
        }
    }