# Problems with Sort Index by Value node

**URL:** <https://forum.dynamobim.com/t/problems-with-sort-index-by-value-node/19963>\
**Category:** Lists-Logic\
**Created:** [March 13, 2018, 9:57am UTC](https://forum.dynamobim.com/t/problems-with-sort-index-by-value-node/19963 "2018-03-13T09:57:00Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cristiano](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@Cristiano](https://forum.dynamobim.com/u/Cristiano)\
**Post date:** [March 13, 2018, 9:57am UTC](https://forum.dynamobim.com/t/problems-with-sort-index-by-value-node/19963/1 "2018-03-13T09:57:00Z")

</div>

I’m trying to sort some elements by their y,z positions but the sort index by value node doesn’t return the correct order of number values. Where am I doing wrong?

 ![2018-03-13%2010_53_20-Dynamo](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/a/3a1e9a7b6c79872b7251abd53b792649e397ee5d.png)

---

<div class="post-metadata">

**Author:** ![PauLtus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paultus/32/48502_2.png) [@PauLtus](https://forum.dynamobim.com/u/PauLtus)\
**Post date:** [March 13, 2018, 10:01am UTC](https://forum.dynamobim.com/t/problems-with-sort-index-by-value-node/19963/2 "2018-03-13T10:01:16Z")

</div>

I actually think the `SortIndexByValue` node does exactly what it’s supposed to do.  
What is the result you’d want?

---

<div class="post-metadata">

**Author:** ![Cristiano](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@Cristiano](https://forum.dynamobim.com/u/Cristiano)\
**Post date:** [March 13, 2018, 10:05am UTC](https://forum.dynamobim.com/t/problems-with-sort-index-by-value-node/19963/3 "2018-03-13T10:05:03Z")

</div>

I think it should assign “0” to the smallest number and “5” to the biggest one, but it does’nt do that.

---

<div class="post-metadata">

**Author:** ![PauLtus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paultus/32/48502_2.png) [@PauLtus](https://forum.dynamobim.com/u/PauLtus)\
**Post date:** [March 13, 2018, 10:08am UTC](https://forum.dynamobim.com/t/problems-with-sort-index-by-value-node/19963/4 "2018-03-13T10:08:54Z")

</div>

But 104137 is the smallest number and 104396 the largest aren’t they?  
Do you want to sort the list based on values instead of getting the indices?

---

<div class="post-metadata">

**Author:** ![Cristiano](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@Cristiano](https://forum.dynamobim.com/u/Cristiano)\
**Post date:** [March 13, 2018, 10:33am UTC](https://forum.dynamobim.com/t/problems-with-sort-index-by-value-node/19963/5 "2018-03-13T10:33:19Z")

</div>

Yes it’s correct, so why 104137 which is the smallest one returns “4” and 104396 which is the largest one returns “1”?  
I think something is not working in the node.  
I need indexes, I don’t want to sort elements. I just want to assign a progressive number to these elements.

---

<div class="post-metadata">

**Author:** ![PauLtus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paultus/32/48502_2.png) [@PauLtus](https://forum.dynamobim.com/u/PauLtus)\
**Post date:** [March 13, 2018, 10:36am UTC](https://forum.dynamobim.com/t/problems-with-sort-index-by-value-node/19963/6 "2018-03-13T10:36:00Z")

</div>

Aha, I see your problem.  
You’re reading it quite the opposite way to what it’s doing.  
With the first being 3, it means that the number at index 3 (so 104137) has the lowest value, and the highest value has index 2 (so 104369)

---

<div class="post-metadata">

**Author:** ![Cristiano](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@Cristiano](https://forum.dynamobim.com/u/Cristiano)\
**Post date:** [March 13, 2018, 11:09am UTC](https://forum.dynamobim.com/t/problems-with-sort-index-by-value-node/19963/7 "2018-03-13T11:09:44Z")

</div>

Many thanks @PauLtus ! I just understood how the node works thanks to you.

---

<div class="post-metadata">

**Author:** ![PauLtus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paultus/32/48502_2.png) [@PauLtus](https://forum.dynamobim.com/u/PauLtus)\
**Post date:** [March 13, 2018, 11:22am UTC](https://forum.dynamobim.com/t/problems-with-sort-index-by-value-node/19963/8 "2018-03-13T11:22:20Z")

</div>

I’m actually fairly certain that if you put the result of the `SortIndexByValue` node through another `SortIndexByValue` node you’ll get the result you wanted 😉

---

<div class="post-metadata">

**Author:** ![Nico\_Stegeman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nico_stegeman/32/19204_2.png) [@Nico\_Stegeman](https://forum.dynamobim.com/u/Nico_Stegeman)\
**Post date:** [March 13, 2018, 11:25am UTC](https://forum.dynamobim.com/t/problems-with-sort-index-by-value-node/19963/9 "2018-03-13T11:25:04Z")

</div>

![sort](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/1/e1a9bcee7b364390953d2392dbdcf87a7ddfb0fa.PNG)  
Paul same thought here:wink:

---

<div class="post-metadata">

**Author:** ![Cristiano](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@Cristiano](https://forum.dynamobim.com/u/Cristiano)\
**Post date:** [March 13, 2018, 11:33am UTC](https://forum.dynamobim.com/t/problems-with-sort-index-by-value-node/19963/10 "2018-03-13T11:33:10Z")

</div>

Great! That’s true. I resolved sorting elements by their positions and then assigning a progressive number, but I might as well use your solution.

 ![2018-03-13%2012_31_26-Dynamo](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/5/35be4f71e98266fb4c87c986d7a988aa02922382.png)

---

<div class="post-metadata">

**Author:** ![PauLtus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paultus/32/48502_2.png) [@PauLtus](https://forum.dynamobim.com/u/PauLtus)\
**Post date:** [March 13, 2018, 11:36am UTC](https://forum.dynamobim.com/t/problems-with-sort-index-by-value-node/19963/11 "2018-03-13T11:36:27Z")

</div>

> [@PauLtus](#):
>
> Do you want to sort the list based on values instead of getting the indices?

😉

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [March 13, 2018, 5:17pm UTC](https://forum.dynamobim.com/t/problems-with-sort-index-by-value-node/19963/12 "2018-03-13T17:17:04Z")

</div>

> [@Cristiano](#):
>
> I just want to assign a progressive number to these elements.

![SortIndex](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/1/71278f9135e814ca75f6c0707c163fb1516ac6f4.png)
