方法:利用数组交换位置
sub 字典排序()
s = 0
Dim arr(dic1.keys)'将字典key和value存入一个数组中
For Each ke In dic1.keysarr(s) = Array(ke, dic1(ke))s = s + 1
Next'进行排序
For i = LBound(arr) To UBound(arr) - 1For j = i + 1 To UBound(arr)If arr(i)(1) > arr(j)(1) Then'交换位置temp = arr(i)arr(i) = arr(j)arr(j) = tempEnd IfNext j
Next i'将排序后的结果输出
For i = LBound(arr) To UBound(arr)Debug.Print arr(i)(0) & " : " & arr(i)(1)
Next i
end sub