Public Class frmProperties
    Private itemsDictionary As Dictionary(Of String, List(Of ItemInfo))
    Private designerForm As FrmDesigner
    Private triggerEditorForm As frmTriggerEditor

    Public Sub New(itemsDictionary As Dictionary(Of String, List(Of ItemInfo)), designerForm As FrmDesigner, triggerEditorForm As frmTriggerEditor)
        InitializeComponent()
        Me.itemsDictionary = itemsDictionary
        Me.designerForm = designerForm
        Me.triggerEditorForm = triggerEditorForm
        PopulateTreeView()
    End Sub

    Private Function GetItemInfoFromNode(node As TreeNode) As ItemInfo
        For Each itemType In itemsDictionary.Keys
            For Each item In itemsDictionary(itemType)
                If node.Text.Contains(item.UniqueId) Then
                    Return item
                End If
            Next
        Next
        Return Nothing
    End Function

    Private Sub PopulateTreeView()
        trvControls.Nodes.Clear()

        ' Dictionary to map item keys to their categories
        Dim itemCategories As New Dictionary(Of String, String) From {
        {"picFlipper1", "Flippers"},
        {"picFlipper2", "Flippers"},
        {"picFlipper3", "Flippers"},
        {"picFlipper4", "Flippers"},
        {"picLaser1", "Lasers"},
        {"picLaser2", "Lasers"}
    }

        ' Dictionary to hold nodes for each category
        Dim categoryNodes As New Dictionary(Of String, TreeNode)

        ' First pass: Create category nodes and add items to them
        For Each itemType In itemsDictionary.Keys
            For Each item In itemsDictionary(itemType)
                Dim category As String = Nothing
                If itemCategories.TryGetValue(item.ImageKey, category) Then
                    If Not categoryNodes.ContainsKey(category) Then
                        categoryNodes(category) = New TreeNode(category)
                    End If
                    Dim parentNode As TreeNode = categoryNodes(category)
                    Dim itemName As String = GetRenamedItem(item.ImageKey)
                    Dim subCategory As String = GetSubCategory(item.ImageKey)

                    Dim subCategoryNode As TreeNode = Nothing
                    For Each node As TreeNode In parentNode.Nodes
                        If node.Text = subCategory Then
                            subCategoryNode = node
                            Exit For
                        End If
                    Next

                    If subCategoryNode Is Nothing Then
                        subCategoryNode = New TreeNode(subCategory)
                        parentNode.Nodes.Add(subCategoryNode)
                    End If

                    Dim childNode As New TreeNode($"{itemName} at ({item.Location.X}, {item.Location.Y}) - {item.UniqueId}")
                    subCategoryNode.Nodes.Add(childNode)
                Else
                    If Not categoryNodes.ContainsKey(itemType) Then
                        categoryNodes(itemType) = New TreeNode(itemType)
                    End If
                    Dim parentNode As TreeNode = categoryNodes(itemType)
                    Dim itemName As String = GetRenamedItem(item.ImageKey)
                    Dim childNode As New TreeNode($"{itemName} at ({item.Location.X}, {item.Location.Y}) - {item.UniqueId}")
                    parentNode.Nodes.Add(childNode)
                End If
            Next
        Next

        ' Update the count in the category and subcategory names
        For Each category In categoryNodes.Keys
            Dim parentNode As TreeNode = categoryNodes(category)
            Dim totalCount As Integer = 0

            ' Count items directly under the category node
            For Each itemNode As TreeNode In parentNode.Nodes
                If itemNode.Nodes.Count > 0 Then
                    ' Count items in subcategories
                    itemNode.Text = $"{itemNode.Text} ({itemNode.Nodes.Count})"
                    totalCount += itemNode.Nodes.Count
                Else
                    totalCount += 1
                End If
            Next

            parentNode.Text = $"{category} ({totalCount})"
        Next

        ' Add category nodes to the tree view
        For Each node In categoryNodes.Values
            trvControls.Nodes.Add(node)
        Next
    End Sub

    Private Function GetRenamedItem(itemKey As String) As String
        Select Case itemKey
            Case "picCoin"
                Return "Coin"
            Case "picFlipper1"
                Return "Flipper Left"
            Case "picFlipper2"
                Return "Flipper Right"
            Case "picFlipper3"
                Return "Flipper Up"
            Case "picFlipper4"
                Return "Flipper Down"
            Case "picLaser1"
                Return "Vertical Laser"
            Case "picLaser2"
                Return "Horizontal Laser"
            Case Else
                Return itemKey.Replace("pic", "")
        End Select
    End Function

    Private Function GetSubCategory(itemKey As String) As String
        Select Case itemKey
            Case "picFlipper1"
                Return "Flipper Left"
            Case "picFlipper2"
                Return "Flipper Right"
            Case "picFlipper3"
                Return "Flipper Up"
            Case "picFlipper4"
                Return "Flipper Down"
            Case "picLaser1"
                Return "Vertical Laser"
            Case "picLaser2"
                Return "Horizontal Laser"
            Case Else
                Return itemKey.Replace("pic", "")
        End Select
    End Function
End Class


Can you make it so tvControls is sorted alphabetically