I basically have a table with headers that I read in from a DB using linq in C#. Of these headers, there is always at least one that is always the same; Total and I want it to always be on the right.
So here is sort of how my data is laid out:
Data
{
Label,
Value,
Age //Not used initially
}
Sample Data:
{"Dog", 7}
{"Cat", 3}
{"Other", 4}
{"Total", 14}
I'd like to order the labels in this order; the actual animal names are sorted by their value in descending order and Total is appended to the end:
"Dog", "Other", "Cat", "Total"
How do I do this in Linq. How do I order an attribute based upon the value of another attribute?
Once I have the order of the headers, is there an easy way to order future rows based upon the already determined order. If I want to initially find headers where(x=>x.Age > 20) how can I sort the Labels in where(x=>x.Age <= 20) based upon the same ordering as the >20 set?