1 Private Function AlphaNumericDataSortInDatatable(input As DataTable, Columnname As String, SortType As String) As DataTable 2 Try 3 If input.Rows.Count > 0 Then 4 Dim lobjDic As New Dictionary(Of String, List(Of Integer)) 5 Dim IntegerData As New List(Of Integer) 6 Dim AlpData As New List(Of String) 7 For i As Integer = 0 To input.Rows.Count - 1 8 If CheckInteger(input.Rows(i)(0)) Then 9 IntegerData.Add(CInt(input.Rows(i)(0))) 10 Else 11 AlpData.Add(input.Rows(i)(0)) 12 End If 13 Next 14 IntegerData.Sort() 15 lobjDic.Add("INT", IntegerData) 16 AlpData.Sort() 17 For Each objalp As String In AlpData 18 Dim Key As String = "" 19 Dim ValueObj As New List(Of Integer) 20 For i As Integer = 0 To objalp.Length - 1 21 If CheckInteger(objalp.Substring(i, 1)) Then 22 Key = objalp.Substring(0, i) 23 If Not lobjDic.ContainsKey(Key) Then 24 ValueObj.Add(CInt(objalp.Substring(i, objalp.Length - 1))) 25 lobjDic.Add(Key, ValueObj) 26 Exit For 27 Else 28 ValueObj = lobjDic(Key) 29 ValueObj.Add(CInt(objalp.Substring(i, objalp.Length - 1))) 30 Exit For 31 End If 32 End If 33 Next 34 Next 35 36 For Each keyobj As String In lobjDic.Keys 37 Dim ValueObj As New List(Of Integer) 38 ValueObj = lobjDic(keyobj) 39 ValueObj.Sort() 40 Next 41 Dim ColumnObj As New DataColumn 42 ColumnObj.ColumnName = "Identity" 43 ColumnObj.DataType = GetType(Integer) 44 45 input.Columns.Add(ColumnObj) 46 Dim Cnt As Integer = 1 47 For Each keyobj As String In lobjDic.Keys 48 For Each valueobj As String In lobjDic(keyobj) 49 If keyobj = "INT" Then 50 Dim myRow() As Data.DataRow 51 myRow = input.Select(Columnname & " = '" & valueobj & "'") 52 myRow(0)("Identity") = Cnt 53 Else 54 Dim myRow() As Data.DataRow 55 myRow = input.Select(Columnname & " = '" & keyobj & valueobj & "'") 56 myRow(0)("Identity") = Cnt 57 End If 58 Cnt = Cnt + 1 59 Next 60 Next 61 Dim dvGAmt As New DataView(input) 62 dvGAmt.Sort = "Identity " + SortType 63 Return dvGAmt.Table 64 End If 65 Catch ex As Exception 66 Return input 67 End Try 68 Return input 69 End Function 70 Private Function CheckInteger(ByVal input As String) As Boolean 71 Dim lstrReturn As Boolean = False 72 Try 73 Dim intval As Integer 74 lstrReturn = Integer.TryParse(input, intval) 75 Catch ex As Exception 76 Return False 77 End Try 78 Return lstrReturn 79 End Function