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;} );

```
I've created a solution for this. I've divided the `list` into two part then sort and concat. Please check below:

```
public List<ListItem> getSortedList()
{
    int dummy = 0;

    List<ListItem> list = new List<ListItem>();
    list.Add(new ListItem() { Item = "A" });
    list.Add(new ListItem() { Item = "B" });
    list.Add(new ListItem() { Item = "C" });
    list.Add(new ListItem() { Item = "111" });
    list.Add(new ListItem() { Item = "11" });
    list.Add(new ListItem() { Item = "123" });
    list.Add(new ListItem() { Item = "1" });
    list.Add(new ListItem() { Item = "42" });
    list.Add(new ListItem() { Item = "5" });

    var listNumber = list.Where(m => int.TryParse(m.Item, out dummy)).ToList().OrderBy(m => Convert.ToInt16(m.Item)).ToList();
    var listString = list.Where(m => !int.TryParse(m.Item, out dummy)).ToList().OrderBy(m => m.Item).ToList();

    var sortedList = listNumber.Concat(listString).ToList();

    return sortedList;
}

```

You can run this in [DotNetFiddle](https://dotnetfiddle.net/rfs3du).