Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7861511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:45:58+00:00 2026-06-02T22:45:58+00:00

I am looking for an elegant solution to an ordering problem I am having.

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T22:45:59+00:00Added an answer on June 2, 2026 at 10:45 pm

    You can stack your order’s:

    query
      .OrderBy(item => item.Title) // alphabetical
      .OrderByDescending(item => item.Title == "Main Item"); // put Main Item first, bool==true
    

    EDIT

    The list is preordered, only the 2nd OrderBy is needed int that case

    query.OrderByDescending(item => item.Title == "Main Item");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for an elegant solution to the following problem: I currently have a
I have an interesting problem and I was looking for a solution; Hoping that
I have a situation for which I am looking for a more elegant solution.
I have a problem which has an solution that can be solved by iteration,
I am looking for an elegant solution for the following problem. Let's assume we
I'm looking for an elegant Python program that does a BFS traveral of a
I'm looking for a simple/elegant way to grep a file such that every returned
I am looking at building a shop solution that needs to be scalable. Currently
I am looking for an elegant solution to (within vim script) iterate over all
Looking for advice and elegant solution extracting properties and values into any convenient data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.