If I have a 2D array of strings like so;
{
{"12", "Animal", "Cat"}
{"20", "Animal", "Dog"}
{"6", "Vegetable", "Carrot"}
{"5", "Mineral", "Iron"}
}
How can I use LINQ to select the data and orderby, say the 2nd ‘column’? (C# linq preferably)
Something like:
It’s not clear what you mean by “select the data”. Personally I’d try to create a more strongly-typed data model, rather than just having an array of strings for each row. You can do that easily enough with LINQ as well, of course:
EDIT: For a query expression version of the first:
As you can see, it’s more cluttered than using the extension methods directly. It’s worth being comfortable with both forms, so you can pick the simplest one in any given situation.