Split String to array and Sort Array

Viewed 3178

I am trying to sort a string split by comma. But it is not behaving as expected

var classes = "10,7,8,9";
Console.Write(string.Join(",", classes.Split(',').OrderBy(x => x)));
Console.ReadKey();

and output is

10,7,8,9

But I want the expected output to be like:

7,8,9,10

Classes can have a section along with them. like 7a,7b

and I want to achieve it on one line of code.

6 Answers
Related