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 7556065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:46:37+00:00 2026-05-30T11:46:37+00:00

I have a problem when sorting a generic list in C# I have a

  • 0

I have a problem when sorting a generic list in C#

I have a List<MyObjects> myList, and MyObject has a string property.

Now it looks like this when sorting descending

2.4.88

2.4.70

2.4.164 -> this is wrong

2.4.15

How do I sort my list?

I have tried:

myList.sort(delegate(MyObjects obj1, MyObjects obj2)
{
    return obj2.version.CompareTo(obj1.version);
});

Its not an option to use Linq (older framework)

UPDATE: My list can also contains N/A

  • 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-30T11:46:38+00:00Added an answer on May 30, 2026 at 11:46 am

    You cannot compare as strings, because obviously thats the proper string sorting. You need to parse to numbers or to an instance of the Version class:

    myList.sort(delegate(MyObjects obj1, MyObjects obj2)
    {
        return new Version(obj2.version).CompareTo(new Version(obj1.version));
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with how the List Sort method deals with sorting. Given
I have a problem sorting vectors in 2D vector? I would like to sort
I have a little problem with sorting out a list using an implementation of
I have a problem with sorting NSTableColumn contents. In my NSTableView there are three
I have a problem with sorting items in table in PHP. Here is what
I have a complex sorting problem with my SQL statement. I have a table
I have a problem on using LinqToSQL with paging + dynamic sorting. These are
I am currently faced with a difficult sorting problem. I have a collection of
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have a method for sorting generic lists by the object fields: public static

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.