fork download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var oldList = new []{"First","Second","Third","Fourth","Fifth","Sixth","Seventh"};
  10. var newArray = oldList.Select((t, index) => new { t, index })
  11. .OrderBy(x => x.index == 1 || x.index == 2)
  12. .ThenBy(x => x.index)
  13. .Select(x => x.t)
  14. .ToArray();
  15. foreach(var t in newArray)
  16. Console.WriteLine(t);
  17. }
  18. }
Success #stdin #stdout 0.05s 37088KB
stdin
Standard input is empty
stdout
First
Fourth
Fifth
Sixth
Seventh
Second
Third