I'm trying to Sort a DataTable with LINQ based on 2 columns. I want to sort it by:
- Date column first
- Category column second, and in this column to be a custom sort: Here I have "Altele", "Ingrasaminte","Pesticide", "Seminte","Motorina". And I would like the order to be "Ingrasaminte", "Motorina", "Pesticide", "Seminte" and "Altele" last.
This is what I have so far: (From x In dataTable.AsEnumerable() Order By Convert.ToString(x("Date")), Convert.ToString(x("Category")) Select x).CopyToDataTable
This puts "Altele" first in Category column and I would like it to be last.
DataTable Example
Date Category TURN INTO => Date Category
21.05.2022 Altele 21.05.2022 Ingrasaminte
22.05.2022 Altele 21.05.2022 Motorina
21.05.2022 Pesticide 21.05.2022 Pesticide
22.05.2022 Pesticide 21.05.2022 Seminte
21.05.2022 Ingrasaminte 21.05.2022 Altele
22.05.2022 Ingrasaminte 22.05.2022 Ingrasaminte
21.05.2022 Motorina 22.05.2022 Motorina
22.05.2022 Motorina 22.05.2022 Pesticide
21.05.2022 Seminte 22.05.2022 Seminte
22.05.2022 Seminte 22.05.2022 Altele
Can you help please ?