记录一下TreeMap对数据的排序,有点像桶排
public static void mysort(int[] nums)
{
TreeMap<Integer,Integer>data = new TreeMap<>();
for(int i=0;i<nums.length;i++)
data.put(nums[i],data.getOrDefault(nums[i],0)+1);
int j=0;
Iterator it = data.entrySet().iterator();
while(it.hasNext())
{
Map.Entry<Integer,Integer>entry = (Map.Entry)it.next();
int size = entry.getValue();
int key = entry.getKey();
while(size--!=0)
nums[j++] = key;
}
}