I’m having a problem where the `break;`

command is acting like `return;`

and ending the whole script.

The function of the script it a 1D bin packing

At the end of the code, i have a for loop inside another for loop, but when the script encounters the `break;`

, it seems to end the script.

as seen in the screenshot, the bottom component (scripted in python) runs thru all the numbers, but the one on the top stops.

Can someone take a look and explain why I’m having this problem? thanks.

C# script:

```
List<double> sort = new List<double>();
DA.GetDataList("Values", sort);
sort.Sort((a, b) => -1 * a.CompareTo(b));
DataTree<double> sorted = new DataTree<double>();
double max = 0.0;
DA.GetData("Max Sum", ref max);
List<double> exceeded = new List<double>();
int j = 0;
for (int i = 0; i < sort.Count; i++)
{
if (sort[i] > max)
{
exceeded.Add(sort[i]);
continue;
}
GH_Path path = new GH_Path(j);
List<double> sumCheck = new List<double>();
if (sorted.Branch(path) != null)
sumCheck = sorted.Branch(path);
else
sumCheck.Add(0.0);
if (sumCheck.Sum() + sort[i] <= max)
sorted.Add(sort[i], path);
else
{
for (int k =i+1;k<sort.Count;k++)
{
if (sumCheck.Sum() + sort[k] <= max)
{
sorted.Add(sort[k], path);
sort.Remove(k);
break;
}
if (k == sort.Count)
{
j++;
sorted.Add(sort[i], path);
break;
}
}
}
}
DA.SetDataTree(0, sorted);
DA.SetDataList(1, exceeded);
```