'Description: Sort a map by its keys in ascending order
'Tag: map, sort, asc
Sub SortMapKeys (m As Map, SortAsc As Boolean)
Private KeysList As List
Private m2 As Map
Private key As String
Private mVal As Object
Private i As Int
KeysList.Initialize
m2.Initialize
' get all the keys
KeysList = m.Keys
KeysList.Sort(True)
For i= 0 To KeysList.Size - 1
key = KeysList.Get(i)
mVal = m.Get(key)
m2.Put(key, mVal)
Next
m.Clear
For Each m2Key As String In m2.Keys
m.Put(m2Key, m2.Get(m2Key))
Next
End Sub