using System; using System.Linq; using System.Collections.Generic; using System.Globalization; using System.Net; public class Test { public static void Main() { var strings = new List() { "RS01","RS05A","RS10","RS102","RS105A","RS105B","RS32A","RS80" }; var sorted = strings.Select(str => new { str, num = int.Parse(new string(str.Skip(2).TakeWhile(Char.IsDigit).ToArray())), containsVersion = str.Skip(2).SkipWhile(Char.IsDigit).Any() }).Select(x => new{x.str, x.num, x.containsVersion, version = !x.containsVersion ? "" : new string(x.str.Skip(2).SkipWhile(Char.IsDigit).ToArray()) }) .OrderBy(x => x.num).ThenBy(x => x.version); foreach(var x in sorted) Console.WriteLine(x.str); } }