1. 샘플 코드

1-1. Map<String,Integer>

1-1-1. 메인 코드

		Map myMap = new HashMap();
		myMap.put("aa",13);
		myMap.put("ab",12);
		myMap.put("ac",11);
		System.out.println(myMap);
		Map newMap = sortByValue(myMap);
		System.out.println(newMap);

1-1-2. 추가 메소드

    public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) {
        List<Entry<K, V>> list = new ArrayList<>(map.entrySet());
        list.sort(Entry.comparingByValue());

        Map<K, V> result = new LinkedHashMap<>();
        for (Entry<K, V> entry : list) {
            result.put(entry.getKey(), entry.getValue());
        }

        return result;
    }

1-1-3. 실행 결과

{aa=13, ab=12, ac=11}
{ac=11, ab=12, aa=13}

1-2. Map<Integer,String>

1-2-1. 샘플 코드

		Map myMap = new HashMap();
		myMap.put(11, "ac");
		myMap.put(12, "ab");
		myMap.put(13, "aa");
		System.out.println(myMap);
		Map newMap = sortByValue(myMap);
		System.out.println(newMap);

1-2-2. 추가 메소드

	public static LinkedHashMap<Integer, String> sortByValue(Map<Integer, String> map) {
		List<Integer> mapKeys = new ArrayList<>(map.keySet());
		List<String> mapValues = new ArrayList<>(map.values());
		Collections.sort(mapValues);
		Collections.sort(mapKeys);

		LinkedHashMap<Integer, String> sortedMap = new LinkedHashMap<>();

		Iterator<String> valueIt = mapValues.iterator();
		while (valueIt.hasNext()) {
			String val = valueIt.next();
			Iterator<Integer> keyIt = mapKeys.iterator();

			while (keyIt.hasNext()) {
				Integer key = keyIt.next();
				String comp1 = map.get(key);
				String comp2 = val;

				if (comp1.equals(comp2)) {
					keyIt.remove();
					sortedMap.put(key, val);
					break;
				}
			}
		}
		return sortedMap;
	}

1-2-3. 실행 결과

{11=ac, 12=ab, 13=aa}
{13=aa, 12=ab, 11=ac}