fork download
  1. using System;
  2. using System.Linq;
  3.  
  4. using System.Collections.Generic;
  5.  
  6. namespace Yoba{
  7.  
  8. public class Test
  9. {
  10. public static void Main()
  11. {
  12. var source = new int[] {1, 2, 3, 4, 5, 6, 7};
  13.  
  14. Action<int[]> output = (t) => Console.WriteLine(t.Aggregate(string.Empty, (s, s1)=>string.Format("{0}, {1}", s, s1)).Trim(new char[]{',',' '}));
  15.  
  16. output(source);
  17. source = Enumerable.Range(0, source.Length).Select(x => new {Value = source[x], Group = x / 2, RowNumber = x}).OrderBy(x => x.Group).ThenByDescending(x => x.RowNumber).Select(x => x.Value).ToArray();
  18. output(source);
  19.  
  20.  
  21. }
  22. }
  23. }
Success #stdin #stdout 0.04s 16096KB
stdin
Standard input is empty
stdout
1, 2, 3, 4, 5, 6, 7
2, 1, 4, 3, 6, 5, 7