I have a DataSet that contains a column, call it Type which contains ints. I’m using LINQ to manipulate the DataSet and I want to sort by Type. The Type column only contains 3 values right now (1, 2, 3). I would like to sort so that Type 2 are first in the list and then 1 and 3.
Is there an easy solution for this or am I going to have to customize the OrderBy?
Few solutions :
or probably better
or also elegant Tim Schmelter’s solution
Advantage or Tim Schmelter’s solution : you’re not depending on a “pseudo-value”.
In the two first solutions, we assert that 0 is ((min possible value of the field) -1).
Is this real, can it change, we don’t know.