Sorting a List of strings by 2 decimal points

Viewed 1204

I'm trying to sort a list by a value in one of the x objects the list holds. Here is the order i need:

1
1.1
1.2
1.3
1.4
1.5
1.10
1.11
1.12
4.1
4.2
4.15

I've tried the following:

var lRetItems = lExportItems.OrderBy(d => d.linkid*);

and

IEnumerable<item> lRetItems = 
from x in lExportItems
orderby x.linkid*
select x;

*linkid = string

but neither give me the order i want as with these approaches 1.10 follows 1.1 instead of 1.2 following 1.1. Here's an example of the incorrect ordering the above approaches provide:

1
1.1
1.10
1.11
1.12
1.2
1.3
1.4
...

Does anyone have any idea how i might order the list in the same way as the first example?

If this were a double than 1.10 would be the same as 1.1...hence the ordering above. But i would of expected a string to at least sort by length?

Does anyone know of an approach that could provide the orider i require from these strings?

Here's a Rextester showing what I've tried based off comments (this fails):

http://rextester.com/JJB33165

Thanks.

2 Answers
Related