15,843,149 members
See more:
I have list(A) of 2,30,000 items where 1st item in list is (3,1110000000) here in this example 3 is sum of number 1110000000. and I sorted this list in descending order according to sum and now my 1st item is (57,9657551955). now there are many numbers whose sum is 57 and so on then dump all numbers whose sum is 57 into a file named "57.CSV" and so on. now after sorting the list in descending order I found 57 sum from 0th index to 121th index , 56 sum from 122th index to 178th index. Now i want to create lists from list(A) for all sums 57 , 56 and so on. How to do this?

What I have tried:

```using (StreamReader sr = new StreamReader(fs))
{
string[] Allbarcodes = barcode_data.Split(',');
int counter = 0;

for (int i = 0; i < Allbarcodes.Length - 1; i++)
{
if (!string.IsNullOrEmpty(Allbarcodes[i]))
{
long sumOfnum = Summation(Convert.ToInt64(Allbarcodes[i]));
}
}
Array.Clear(Allbarcodes, 0, Allbarcodes.Length);
label1.Text = counter++.ToString();

result = barcodeList.Select(m => new { value = int.Parse(m.Substring(0, m.IndexOf(','))), item = m }).
OrderByDescending(m => m.value).Select(m => m.item).ToList();
////list result contains all items and have to make sublists of it////
sr.Close();
sr.Dispose();
}```
Posted
Updated 1-Mar-17 1:48am
v2

## Solution 1

v2
Graeme_Grant 1-Mar-17 6:49am
You sneaked under me ... good to see that we both had the same answer. ;)
OriginalGriff 1-Mar-17 7:40am
It's the obvious solution - I added a bit on grouping the results into a dictionary as well.
Graeme_Grant 1-Mar-17 7:44am
yes, that can be a challenge for a newbie...

## Solution 2

Linq's `GroupBy` I think would do what you want.
How to: Group Query Results (C# Programming Guide)[^]