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.<
I have modified your code, and now working fine:
List data = new List { 1, 2, 1, 2, 3,3, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6 };
List> resultLists = new List>();
int last = 0;
int count = 0;
var res = data.Where((p, i) =>
{
if (i > 0)
{
if (p > last && p!=last)
{
resultLists[count].Add(p);
}
else
{
count++;
resultLists.Add(new List());
resultLists[count].Add(p);
}
}
else
{
resultLists.Add(new List());
resultLists[count].Add(p);
}
last = p;
return true;
}).ToList();