bubble sorting a dictionary object ?
I have a dictionary consisting of an array of words as the keys and the number of occurences of each word as the items. I want sort this dictionary by number of occurences of each key, in descending order, so that I may be able to take the top 20 most used words. I want to use a bubble sort but I seem to be having trouble passing my dictionary to the sort function. Here is some of my code...
VB Code:
dict = bubble_sort(dict.items)
Private Function bubble_sort(dict)
Dim i As Long, n As Long, tempN As Long, allOk As Boolean
For n = 0 To UBound(dict)
allOk = True
For i = 0 To UBound(dict) - 1
If dict(i) > dict(i + 1) Then
allOk = False
tempN = dict(i)
dict(i) = dict(i + 1)
dict(i + 1) = tempN
End If Next
If allOk Then Exit For
Next
End Function
What do I appear to be doing incorrectly?