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
You cannot compare as strings, because obviously thats the proper string sorting. You need to parse to numbers or to an instance of the
Versionclass: