I am looking for an elegant solution to an ordering problem I am having.
I have a database query that returns a list of results that is ordered by name. The results will always contain one item called “Main Item” that always needs to appear first in the list of results. This item is not flagged by a separate field in the database and so it needs to be identified by name.
For example, if the results are as follows:
"A Item"
"B Item"
"Main Item"
"Y Item"
"Z Item"
I need the alphabetical sort to remain, but with the exception that “Main Item” appears first:
"Main Item"
"A Item"
"B Item"
"Y Item"
"Z Item"
The query that returns this data is written in pl/sql and I can either modify the query or do something on the .Net side where I have an IEnumerable object containing a collection of the resulting objects.
You can stack your order’s:
EDIT
The list is preordered, only the 2nd
OrderByis needed int that case