不是使用sort  

解决方案 »

  1.   

    public class TestSort { int[] iSort = new int[10];
    Map map = new TreeMap(); void setSort(int[] a) {
    for (int i = 1; i < a.length; i++) {
    a[i] = (int) (Math.random() * 100);
    map.put(a[i], i);
    System.out.println(map.get(a[i]) + "  " + a[i]);
    }
    } void isSort(Map m) { Set set = m.entrySet(); Iterator it = set.iterator(); while (it.hasNext()) {
    Map.Entry entry = (Entry) it.next();
    System.out.println(entry.getValue() + "  " + entry.getKey()); }
    } public static void main(String[] args) {
    TestSort ts = new TestSort();
    ts.setSort(ts.iSort);
    System.out.println("===========");
    ts.isSort(ts.map); }
    }
      

  2.   

    你用Map map = new LinkedHashMap();linkedHashMap是自动排序的Map
      

  3.   

    自定义hash算法给hashMap即可。
      

  4.   

    求你们看一眼Java说明文档Java tutorials行不?我前天刚翻译Map,还被推荐了下。今天就有人问这个问题我真崩溃了。
      

  5.   

    http://java.sun.com/docs/books/tutorial/collections/interfaces/map.html自己去看这个。看不懂就看看词典。哥。
      

  6.   


    我晕,你不要误导哦LinkedHashMap不是自动排序的
    TreeMap才是即使TreeMap也不是按照值排序的,是按键排序
      

  7.   

    迷茫   LinkedHashMap 是记录的