Split C# collection into equal parts, maintaining sort

前端 未结 8 1836
野的像风
野的像风 2021-02-19 18:31

I am trying to split a collection into multiple collections while maintaining a sort I have on the collection. I have tried using the following extension method, but it breaks

8条回答
  •  渐次进展
    2021-02-19 19:09

        double partLength = list.Count() / (double)parts;
    
        int i = 0;
        var splits = from name in list
                     group name by Math.Floor((double)(i++ / partLength)) into part
                     select part;
    

提交回复
热议问题