fork(8) download
  1. using System;
  2. using System.Linq;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var listStr = new[] {
  9. "20170822_10", "20170821_1", "20170823_4", "20170821_10",
  10. "20170822_11", "20170822_5", "20170822_2", "20170821_3",
  11. "20170823_6", "20170823_21", "20170823_20", "20170823_2"
  12. };
  13. var sorted = listStr
  14. .OrderBy(s => s.Split('_')[0])
  15. .ThenBy(s => int.Parse(s.Split('_')[1]));
  16. foreach (var s in sorted) {
  17. Console.WriteLine(s);
  18. }
  19. }
  20. }
Success #stdin #stdout 0.01s 131840KB
stdin
Standard input is empty
stdout
20170821_1
20170821_3
20170821_10
20170822_2
20170822_5
20170822_10
20170822_11
20170823_2
20170823_4
20170823_6
20170823_20
20170823_21