I have 2 generic lists.
Dim Item As New List(Of String)
Dim Item2 As New List(Of Array)
Item conatains 4 elements.
They are 1. Item code
2. Description
3. BIN
4. Price
But they are just entered sequentially
For example
Item={5858545, HairDryer, A45, 50}
There are many Item and Item 2 contains The list of Items.
For example Item2= {{5858545, HairDryer, A45, 50},….}
Now i want to sort the Item2 according to according to the BIN and then By Item code
So now my list Item2 will contains elements of Item sorted according to BIN and then By Item code.
How to do this with LINQ or any other way?
Thanks
You shouldn’t be storing objects as an array or list of values. Create a new class to represent your item. Give it four properties for BIN, name, etc., and then create a list of that custom type.
To order the list you can use the
OrderBymethod, followed by theThenBymethod. It will read much better if you have a custom object, as it will look like:instead of the much uglier option you need to do if you have arrays/lists:
Note how the first example reads exactly like your requirements. “Order the list by BIN and then by Code.” It’s perfectly clear to someone looking at the code for the first time exactly what it’s doing.