Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub SortMethod()
- Dim table As New List(Of List(Of Integer))()
- FillTable(table)
- PrintList(table)
- Const firstSortColumn As Integer = 1
- Const secondSortColumn As Integer = 0
- Const thirdSortColumn As Integer = 2
- Dim tableAfterFirstSorting As IOrderedEnumerable(Of List(Of Integer)) = table.OrderBy(Function(o) o(firstSortColumn))
- Dim tableAterSecondSorting As IOrderedEnumerable(Of List(Of Integer)) = tableAfterFirstSorting.ThenBy(Function(o) o(secondSortColumn))
- Dim tableAfterThirdSorting As IOrderedEnumerable(Of List(Of Integer)) = tableAterSecondSorting.ThenBy(Function(o) o(thirdSortColumn))
- PrintList(tableAfterThirdSorting.ToList())
- End Sub
- Private Sub FillTable(table As List(Of List(Of Integer)))
- Dim rnd As New Random()
- For y As Integer = 0 To 9
- Dim column As New List(Of Integer)()
- For x As Integer = 0 To 2
- column.Add(rnd.[Next](4))
- Next
- table.Add(column)
- Next
- End Sub
- Private Sub PrintList(table As List(Of List(Of Integer)))
- Dim output As String = ""
- For Each row As List(Of Integer) In table
- output = row.Aggregate(output, Function(current, cell) current + (cell + " "))
- output += vbLf
- Next
- output += "=========================" & vbLf
- MessageBox.Show(output)
- End Sub
- '=======================================================
- 'Service provided by Telerik (www.telerik.com)
- 'Conversion powered by NRefactory.
- 'Twitter: @telerik
- 'Facebook: facebook.com/telerik
- '=======================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement