# High - middel - low / value

**URL:** <https://forum.xod.io/t/high-middel-low-value/4511>\
**Category:** Uncategorized\
**Created:** [October 13, 2020, 1:03pm UTC](https://forum.xod.io/t/high-middel-low-value/4511 "2020-10-13T13:03:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![m-b](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@m-b](https://forum.xod.io/u/m-b)\
**Post date:** [October 13, 2020, 1:03pm UTC](https://forum.xod.io/t/high-middel-low-value/4511/1 "2020-10-13T13:03:25Z")

</div>

Hi

I try to use just the middel value at one of the buffer nodes. The values swapt in the buffer like( 5/2/6 or 2/5/6 or 6/2/5) I just want to grap the middel value (5) every time.  
I simply do not find the easiest solution, maybe one of you guys?!

 ![grafik](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/2/21e408f651cd3828df7b40fa3f94bcabf87d9c19.png)

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [October 13, 2020, 2:59pm UTC](https://forum.xod.io/t/high-middel-low-value/4511/2 "2020-10-13T14:59:16Z")

</div>

One option would be to use the min-buffer or min-buf-code from another discussion ([How to write code to place timer values in order from low to high](https://forum.xod.io/t/how-to-write-code-to-place-timer-values-in-order-from-low-to-high/4454/14)) to sort the values for you, then just pull the middle value.

Using min-buff-code, you probably want to RST all the buffers, then push 3 values on (flip-n-times is probably the easiest way to do that), then read the value from the middle buffer.

![image](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/d/d0101bf95be372a9a8faf53deff44d800c38c777.png)  
Since this code assumes you only run once on boot, RST of buffers is not really needed (but would be needed if sequence gets repeated later).  
When flip-n-times-ACT changes to FALSE, you are ready to read your middle value.

---

<div class="post-metadata">

**Author:** ![m-b](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@m-b](https://forum.xod.io/u/m-b)\
**Post date:** [October 14, 2020, 1:51pm UTC](https://forum.xod.io/t/high-middel-low-value/4511/3 "2020-10-14T13:51:02Z")

</div>

Thanks a lot !  
I realy apracieted your suggestion!  
I just make an small change at the min-buff-code. That depends to my values I get from my sensor they incresse and decress in a small time range. I also take now two of the values if thay eqal.  
THX

 ![grafik](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/f/fa432cc211382a4f7b2739e23a8e95e51fadd48b.png)

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [October 14, 2020, 3:15pm UTC](https://forum.xod.io/t/high-middel-low-value/4511/4 "2020-10-14T15:15:16Z")

</div>

If the two values are equal, it doesn’t matter which value goes where, but if you care anyway, use less-or-equal node instead of going crazy with if-else and multiple compares.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/eb7348baa04192c2ef932d1db54d44f09f8a7888.png) [@system](https://forum.xod.io/u/system)\
**Post date:** [November 13, 2020, 3:15pm UTC](https://forum.xod.io/t/high-middel-low-value/4511/5 "2020-11-13T15:15:19Z")

</div>

Closed on November 13, 2020, 3:15pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
