Question: I want to this list

```
A
B
C
111
11
123
1
42
5

```

To be sorted 

```
1
5
11
42
111
123
A
B
C

```

By default, it sorts numbers like strings (So, it goes 1,11,111,123,42,5),
But I want to sort numbers like numbers, and than strings that are not numbers.

Is there clean solution to sort it like above?

It is a list of objects, and object has several properties, one of which is a this string.

Answer: 
This will work for most use cases, but may have odd results if the string starts with control characters, string like "\tabc" will come before the integers:

```
list.OrderBy(x=>int.TryParse(x, out var dummy) ? dummy.ToString("D10") : x);

```

or for versions of C# prior to 7:

```
list.OrderBy(x=> { int dummy; return int.TryParse(x, out dummy) ? dummy.ToString("D10") : x;} );

```
With Regex.Replace in the "OrderBy" it's one (fairly) simple line of code. And note that the number "3" just has to be a number equal-to or larger than your longest string, so for anyone else increase as needed.

```
using System.Text.RegularExpressions;

string[] yourStrings = new string[] { "A", "B", "C", "111", "11", "123", "1", "42", "5" };

foreach (var item in yourStrings.OrderBy(x => Regex.Replace(x, @"\d+", i => 
i.Value.PadLeft(3, '0'))))
{
    Response.Write(item + "\n");
}

```