ついでに選択ソートも
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
Dim Ary() As String For I = 0 To myDIC.Count - 1 ReDim Preserve Ary(1, I) Ary(0, I) = myDIC.keys()(I) Ary(1, I) = myDIC.items()(I) Next I 'Dictionaryから二次元配列に '以下ソート Dim i As Long, j As Long Dim Max As Double, flag As Double Dim newA0 As Long, newB0 As Long _ , newA1 As Double, newB1 As Double, Mark As Long For I = 0 To UBound(Ary, 2) - 1 flag = CDbl(Ary(1, I)) Max = CDbl(Ary(1, I)) Mark = I For j = 1 To UBound(Ary, 2) - I If Max < CDbl(Ary(1, I + j)) Then Max = CDbl(Ary(1, I + j)) Mark = I + j End If Next j newA0 = Ary(0, Mark) newA1 = CStr(Max) newB0 = Ary(0, I) newB1 = CStr(flag) If Not Mark = I Then Ary(0, I) = newA0 Ary(1, I) = newA1 Ary(0, Mark) = newB0 Ary(1, Mark) = newB1 End If Next I |