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

  • Home
  • SEARCH
  • 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 4123652
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:38:19+00:00 2026-05-20T23:38:19+00:00

Based on my previous question , I’ve trying now to have them in the

  • 0

Based on my previous question, I’ve trying now to have them in the following order using the same approach, OrderByDescending and ThenBy

Original (can be in any random order):

1:1
0:0
0:1
2:1
1:0
2:0

Output

2:0 
1:0 
0:0 
2:1 
1:1 
0:1

as you can see, a is descending, and b being ascending. But I’m still not getting the right sort. Any ideas why? Thanks

  • 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-05-20T23:38:20+00:00Added an answer on May 20, 2026 at 11:38 pm

    Think to what you would do manually:

    1. First you must sort the values by the 2nd part in ascending order
    2. Then you must sort values having the same 2nd part, using the 1st part in descending order

    Translated in LINQ it’s pretty the same:

    var sorted = arrayList
    .Cast<string>()
    .Select(x => x.Split(':'))
    .OrderBy(x => x[1])
    .ThenByDescending(x => x[0])
    .Select(x => x[0] + ":" + x[1]);
    

    To clarify a bit more, ThenBy/ThenByDescending methods are used to sort elements that are equal in the previous OrderBy/OrderByDescending, hence the code 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is based on my previous question . I have the following table Table1
Based on a previous question I posed (see here ) and the following msdn
My previous question belied my inexperience and was based on an assumption. Now I
This question is based off of the same app/source from my previous question which
I'm trying to make a wrapper for some C-based sparse-matrix-handling code (see previous question
Based on my previous question here my new concern is how do I unit
Based on the response to this question: Why does C++ have header files and
Based on my previous question I am running a query like so: SELECT DISTINCT
Based on my previous question here and here , I found that I can
Based on a previous question and with a lot of help from Damir Sudarevic

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.