2014-11-01 132 views
-2

我需要按以下順序對映射中提及的符號進行排序。
首先空白,秒*,**第三,第四小寫字母順序字母,按字母順序排列5大寫字母,按升序排列,最後的符號()java爲一些特殊字符,數字,字母和空格排在一起

Map<String, String> symbols = new HashMap<String, String>(); 
    symbols.put("001","*"); 
    symbols.put("002","**"); 
    symbols.put("003"," "); 
    symbols.put("004","s"); 
    symbols.put("005","A"); 
    symbols.put("006","g"); 
    symbols.put("007","f"); 
    symbols.put("008","6"); 
    symbols.put("009","9"); 
    symbols.put("0010","()"); 
    symbols.put("0011","*"); 
    symbols.put("0012","10"); 
    symbols.put("0013","Y"); 
    symbols.put("0014","**"); 
    symbols.put("0015","()"); 
    symbols.put("0016","**"); 
    symbols.put("0017"," "); 

爲清楚起見第6號:最終解決方案就像我提到的那樣,將LinkedHashMap與排序記錄相結合。

+2

什麼是你的問題?你的嘗試在哪裏? – Ezequiel 2014-11-01 10:26:12

回答

2

將這項工作對你

` Map<Integer, String> symbols = new HashMap<Integer, String>(); 
     symbols.put(1,"*"); 
     symbols.put(2,"**"); 
     .............` 
+0

不應該改變地圖的關鍵。這是必要的。 – user3924979 2014-11-01 10:39:59

+0

對不起,對於鍵爲整數,認爲它很容易排序 – 2014-11-01 10:40:56

+0

我需要根據地圖的值進行排序。 – user3924979 2014-11-01 10:42:14

相關問題