I\'ve a List of int and I want to create multiple List after splitting the original list when a lower or same number is found. Numbers are not in sorted order.<
This is my simple loop approach using some yields :
static IEnumerable> Split(IList data)
{
if (data.Count == 0) yield break;
List curr = new List();
curr.Add(data[0]);
int last = data[0];
for (int i = 1; i < data.Count; i++)
{
if (data[i] <= last)
{
yield return curr;
curr = new List();
}
curr.Add(data[i]);
last = data[i];
}
yield return curr;
}