Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var foo = new int[]{1,1,4,5,6,2,3,3,1,7,2,4,2,3};
- foo
- .Aggregate(new List<List<int>>(), (seed, next) => {
- var listToAddTo = seed.FirstOrDefault(l=> !l.Contains(next));
- if (listToAddTo == null)
- {
- seed.Add(new List<int>(){ next });
- }
- else {
- listToAddTo.Add(next);
- }
- return seed;
- })
- .Select(x => x.OrderBy(y => y))
- .SelectMany(x => x);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement