import java.util.*;
import java.util.stream.*;
class Main {
	public static void main(String[] args){
		Map<String, Integer> map = Map.of("A", 25, "D", 10, "B", 15, "E", 15, "C", 17);
		Map<String, Integer> result = map.entrySet().stream()
		    .sorted(Comparator.<Map.Entry<String, Integer>>comparingInt(Map.Entry::getValue)
		       .reversed().thenComparing(Map.Entry::getKey))
		    .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, 
		         (a,b)->b, LinkedHashMap::new));
		System.out.println(result);
	}
}