我建议使用List(Of Tuple)
代替数组,它更具有动态性。请查看以下代码:
Sub SortList()
'Declare the List Of Tuple with a Tuple of Char, Integer, Integer
Dim lstToSort As New List(Of Tuple(Of Char, Integer, Integer))
'Example to Add items
lstToSort.Add(Tuple.Create("R"c, 250645, 11))
lstToSort.Add(Tuple.Create("C"c, 125212, 25))
'Sort is just 1 line
lstToSort = lstToSort.OrderBy(Function(i) i.Item2).ToList
'Loop through the elements to print them
For Each tpl As Tuple(Of Char, Integer, Integer) In lstToSort
Console.WriteLine(tpl.Item1 & "-" & tpl.Item2 & "," & tpl.Item3)
Next
End Sub
编辑:根据您对问题的编辑,以下是修复后的代码:
Sub SortList()
'Declare the List Of Tuple with a tuple of String, Integer
Dim lstToSort As New List(Of Tuple(Of String, Integer))
'Example to add items
lstToSort.Add(Tuple.Create("R-250645", 11))
lstToSort.Add(Tuple.Create("C-125212", 25))
'Sort is just 1 line
lstToSort = lstToSort.OrderBy(Function(i) i.Item2).ToList
'Loop through the elements to print them
For Each tpl As Tuple(Of String, Integer) In lstToSort
Console.WriteLine(tpl.Item1 & "," & tpl.Item2)
Next
End Sub
请尝试并让我知道您的评论。
Char
-Integer
,Integer
数据,您想按第二列进行排序。 - 3vts