Split list by "Higher Than" Value (or Indices)

Hi everyone,

I have two lists, 1 list contains a lot of doubles (from a list.sortbykey node). And another list with “Chopping” values. For example:


I would like to sort my list each time the values in the upper list exceed the values in the bottom list. I did some testing myself but I haven’t found a good solution yet.

In example, the method below sorts the list by lengths instead of indices, this causes only the first index of each sublist to be sorted as wanted, also does the List.Chop node keep chopping according to those values, even when the list lacing is set to shortest.

Split List by Indices.dyn (15.3 KB)

Do you want to chop the values, let’s say in sublist 0 that are between 50 and 100?

Yes exactly that!

Try this:

bools = x<1><2>>y<1>;
count = List.Count(List.UniqueItems(bools<1><2>)<1><2>);
idx1 = List.AllIndicesOf(count<2>,1);
idx2 = List.AllIndicesOf(count<2>,2);
start = List.Transpose(
end = List.Transpose(
lst_chopped = List.Slice(x<1>,start<1>,end<1>,1);

Just tested it and it works great! Thanks a lot :slight_smile:

Would this also work when I have multiple chop values? In my full script it could occur that the amount of chop values varies per sublist

I don’t think it would work if the sublists have more than 2 values. But if you post an example we can make it work or even make something more fancy :slight_smile: