Public Class Form1 ' Sortで利用 Private listHoges As List(Of KeyValuePair(Of String, Integer)) ' データを格納 Private dict As New Dictionary(Of String, Integer) Sub New() ' この呼び出しは、Windows フォーム デザイナで必要です。 InitializeComponent() ' InitializeComponent() 呼び出しの後で初期化を追加します。 listHoges = New List(Of KeyValuePair(Of String, Integer)) dict = New Dictionary(Of String, Integer) End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load dict("Hoge1") = 125 dict("Hoge2") = 63 dict("Hoge3") = 255 dict("Hoge4") = 3 dict("Hoge5") = 64 listHoges.AddRange(dict) Console.WriteLine(vbCrLf & "■ソート前") ' 格納順に表示 For Each KeyPair As KeyValuePair(Of String, Integer) In listHoges Console.WriteLine(KeyPair.Key & "■" & KeyPair.Value) Next End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click listHoges = Me.scheduleSort(dict) Console.WriteLine(vbCrLf & "■ソート後") For Each KeyPair As KeyValuePair(Of String, Integer) In listHoges Console.WriteLine(KeyPair.Key & "■" & KeyPair.Value) Next End Sub ''' <summary> ''' ソートを行う。 ''' </summary> ''' <param name="dict">格納されたデータ</param> ''' <returns>ソート後のリスト</returns> Protected Function scheduleSort(ByVal dict As Dictionary(Of String, Integer)) As List(Of KeyValuePair(Of String, Integer)) Dim lists As New List(Of KeyValuePair(Of String, Integer))(dict) ' lists.Sort(Function(keyPair1 As KeyValuePair(Of String, Integer), keyPair2 As KeyValuePair(Of String, Integer)) keyPair2.Value - keyPair1.Value) lists.Sort(Function(keyPair1 As KeyValuePair(Of String, Integer), keyPair2 As KeyValuePair(Of String, Integer)) keyPair1.Value - keyPair2.Value) Return lists End Function End Class