Sort any Collection by a certain property using Insertion Sort Algorithm in VB.Net
This post is a just a Vb.Net Version of the code explained in this POST <Extension()> _ Public Sub SortCollection(Of T)(ByRef items As List(Of T), ByVal propertyName As String, Optional ByVal sortDirection As String = "asc") Dim tmpItem As Object Dim value As New Object Dim value2 As New Object Dim j As Integer Dim insertItem As Boolean Select Case sortDirection.ToLower Case "asc" Try If items.Count > 1 Then Dim itemType As String = items(0).GetType().GetProperty(propertyName).GetValue(items(0), Nothing).GetType().ToString() For i As Integer = 1 To items.Count - 1 j = i - 1 insertItem = False tmpItem = items(i) value = items(i).GetType().GetProperty(propertyName).GetValue(items(i), Nothing) Do Until insertItem ...