fork download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Globalization;
  5. using System.Net;
  6.  
  7.  
  8.  
  9. public class Test
  10. {
  11. public static void Main()
  12. {
  13. var strings = new List<string>() {
  14. "RS01","RS05A","RS10","RS102","RS105A","RS105B","RS32A","RS80"
  15. };
  16. var sorted = strings.Select(str => new
  17. {
  18. str,
  19. num = int.Parse(new string(str.Skip(2).TakeWhile(Char.IsDigit).ToArray())),
  20. containsVersion = str.Skip(2).SkipWhile(Char.IsDigit).Any()
  21. }).Select(x => new{x.str, x.num, x.containsVersion,
  22. version = !x.containsVersion ? "" : new string(x.str.Skip(2).SkipWhile(Char.IsDigit).ToArray())
  23. })
  24. .OrderBy(x => x.num).ThenBy(x => x.version);
  25.  
  26. foreach(var x in sorted)
  27. Console.WriteLine(x.str);
  28. }
  29. }
  30.  
  31.  
  32.  
Success #stdin #stdout 0.07s 35112KB
stdin
Standard input is empty
stdout
RS01
RS05A
RS10
RS32A
RS80
RS102
RS105A
RS105B