I am having 20 records
I want to order the records in terms of Priority
field.
Priority
field is having 3 values( High, Medium, Low
)
I want to display the records in High, Medium, Low
records in sequence respectively.
var groupedRecords = records.GroupBy(x => x.Priority == "High") // confused here...
Note: I want to get first all High records, then Medium records and atlast Low records.
Why not map the priorities to, say, integers:
High -> 1
Medium -> 2
Low -> 3
So it can be something like this:
var groupedRecords = records.
OrderBy(x => (x.Priority == "High")
? 1
: (x.Priority == "Medium") ? 2 : 3);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With