So I have a class that contains a property called myNumber. It looks like this:
public class MyThing
{
public int name{ get; set; }
public string myNumber{ get; set; }
}
The value contained in myNumber can look like this 12-24 or 12-024.
I would like to order a collection of these objects (IEnumerable<MyThing> myCollection) by myNumber descending but I am not sure how to go about doing this.
I tried myCollection.OrderByDescending(f => f.myNumber) but its not quite what I was expecting. I would expect 12-22, 13-01, 12-030 to order like this:
13-01
12-030
12-22
You can order it like a
Version. Therefore you can split by'-'and use the first part as major- and the last part as minor version:Demo with your desired result.