I have a list like this:
Dim Results_List As New List(Of Tuple(Of String, String, Long))
With those contents:
(B, a, 5000)
(G, a, 1000)
(B, b, 8000)
(G, b, 2000)
Can I use LINQ (or whateverelse but not using a slow FOR) to sort the items by the Long numbers in ascending mode as this?:
(G, a, 1000)
(G, b, 2000)
(B, a, 5000)
(B, b, 8000)
var sortedItems = list.OrderBy(t => t.Item3);
Yes, even by using the internal Sort of List:
Results_List.Sort(Function(p As Tuple(Of String, String, Long), q As Tuple(Of String, String, Long)) p.Item3.CompareTo(q.Item3))
Note that this will sort the Results_List directly, while the OrderBy will returned a new, sorted, enumerable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With