Home > Generics > Sorting Dictionary(of String, Integer) Keys

Sorting Dictionary(of String, Integer) Keys

Need to sort a diction by the String Keys?

 


' Get list of keys.
 Dim keys As List(Of String) = EMailSessionTotals.Keys.ToList

 ' Sort the keys.
 keys.Sort()

 ' Loop over the sorted keys.
 Dim str As String
 For Each str In keys
 _counter += 1
 Dim _li As New ListViewItem
 _li.Text = str
 _li.SubItems.Add(EMailSessionTotals.Item(str).ToString)
 If _counter Mod 2 = 0 Then
 _li.BackColor = Color.LightGray
 End If
 lsvSessionTotals.Items.Add(_li)
 Next

Advertisements
Categories: Generics Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: