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

**URL:** <https://forum.dynamobim.com/t/split-list-by-higher-than-value-or-indices/70535>\
**Category:** Lists-Logic\
**Tags:** dynamo\
**Created:** [November 18, 2021, 1:24pm UTC](https://forum.dynamobim.com/t/split-list-by-higher-than-value-or-indices/70535 "2021-11-18T13:24:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [November 18, 2021, 1:24pm UTC](https://forum.dynamobim.com/t/split-list-by-higher-than-value-or-indices/70535/1 "2021-11-18T13:24:29Z")

</div>

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:

> [0…360…#100,0…360…#90,0…360…#95];  
> [[50,100],[110,210],[120,220]];

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.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/5/d5a92c6ff8bf8b93f62a8e2e2a1f9df0c76f4370.png)

[Split List by Indices.dyn](https://forum.dynamobim.com/uploads/short-url/pQSNJOef7N7Sqp5T0QgJpJ17ob7.dyn) (15.3 KB)

---

<div class="post-metadata">

**Author:** ![EdsonMatt](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/edsonmatt/32/124725_2.png) [@EdsonMatt](https://forum.dynamobim.com/u/EdsonMatt)\
**Post date:** [November 18, 2021, 11:22pm UTC](https://forum.dynamobim.com/t/split-list-by-higher-than-value-or-indices/70535/2 "2021-11-18T23:22:47Z")

</div>

> [@Daan](#):
>
> I would like to sort my list each time the values in the upper list exceed the values in the bottom list.

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

---

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [November 19, 2021, 1:25am UTC](https://forum.dynamobim.com/t/split-list-by-higher-than-value-or-indices/70535/3 "2021-11-19T01:25:29Z")

</div>

Yes exactly that!

---

<div class="post-metadata">

**Author:** ![EdsonMatt](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/edsonmatt/32/124725_2.png) [@EdsonMatt](https://forum.dynamobim.com/u/EdsonMatt)\
**Post date:** [November 19, 2021, 3:44am UTC](https://forum.dynamobim.com/t/split-list-by-higher-than-value-or-indices/70535/4 "2021-11-19T03:44:26Z")

</div>

Try this:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/d/cd380e17f59fa9feb6afc874f1a2bb0e97f5c12a.png)

```auto
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(
[List.FirstItem(idx1<2>),List.FirstItem(idx2<2>),List.LastItem(idx2<2>)+1]);
end = List.Transpose(
[List.FirstItem(idx2<2>),List.LastItem(idx2<2>)+1,List.LastItem(idx1<2>)+1]);
lst_chopped = List.Slice(x<1>,start<1>,end<1>,1);

```

---

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [November 19, 2021, 8:51am UTC](https://forum.dynamobim.com/t/split-list-by-higher-than-value-or-indices/70535/5 "2021-11-19T08:51:39Z")

</div>

Just tested it and it works great! Thanks a lot 🙂

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

---

<div class="post-metadata">

**Author:** ![EdsonMatt](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/edsonmatt/32/124725_2.png) [@EdsonMatt](https://forum.dynamobim.com/u/EdsonMatt)\
**Post date:** [November 19, 2021, 12:51pm UTC](https://forum.dynamobim.com/t/split-list-by-higher-than-value-or-indices/70535/6 "2021-11-19T12:51:30Z")

</div>

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 🙂
