fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. string[] things= new string[] { "100-1", "100-11", "100-3", "100-20" };
  10. IEnumerable<string> ordered = things
  11. .Select(s => new
  12. {
  13. str = s,
  14. firstPart = s.Split('-').ElementAtOrDefault(0),
  15. secondPart = s.Split('-').ElementAtOrDefault(1)
  16. })
  17. .OrderBy(x => int.Parse(x.firstPart))
  18. .ThenBy(x => int.Parse(x.firstPart))
  19. .Select(x => x.str);
  20.  
  21. foreach (string s in ordered)
  22. Console.WriteLine(s);
  23. }
  24. }
Success #stdin #stdout 0.05s 38160KB
stdin
Standard input is empty
stdout
100-1
100-11
100-3
100-20