C# Collection - Order by an element (Rotate)

后端 未结 6 546
迷失自我
迷失自我 2021-01-23 17:05

I have an IEnumerable collection. Lets say it contains 5 points (in reality it is more like 2000)

I want to order this collection so that a spe

6条回答
  •  没有蜡笔的小新
    2021-01-23 17:46

    var list = new[] { 1, 2, 3, 4, 5 };
    
    var rotated = list.Skip(3).Concat(list.Take(3));
    
    // rotated is now {4, 5, 1, 2, 3}
    

提交回复
热议问题