Welcome to the Blogcast Repository Sign in | Join | Help
Search BlogCastRepository.com for:
in Search

239 BlogCasts in The BlogCast Repository!

Matt Broadstock

Check us out!
SMS Utilities

VBS - Sorting a dictionary object

All of the examples that I found on the internet were WAY too complicated and hard to follow. Here is a very simple dictionary sort function that I figured I would share.

 

Function SortDict(ByVal objDict)
 'Call using "Set objDictSorted = SortDict(objDict)"
 
 Dim i, j, temp
 
 For Each i In objDict
  For Each j In objDict
   If(objDict.Item(i) <= objDict.Item(j)) Then
    temp = objDict.Item(i)
    objDict.Item(i) = objDict.Item(j)
    objDict.Item(j) = temp
   End If
  Next
 Next

 'For Each i In objDict
 ' WScript.Echo objDict.Item(i)
 'Next

 Set SortDict = objDict

End Function

keyword: sortdictionary

Share this post:                                       

Comments

No Comments