Java HashMap按value进行排序

public void FindNumsAppearOnce(int [] array,int num1[] , int num2[]) {
        if(array.length<=0|| array==null)   return;
        HashMap map=new HashMap<>();
        for(int i=0;i> list=new ArrayList<>(map.entrySet());
        Collections.sort(list, new Comparator>() {
            @Override
            public int compare(Map.Entry o1, Map.Entry o2) {
                return o1.getValue().compareTo(o2.getValue());
            }
        });
        num1[0]=list.get(0).getKey();
        num2[0]=list.get(1).getKey();
    }

你可能感兴趣的:(JAVA)