How to write code to place timer values in order from low to high

Slightly different approach (not any better…just different; in fact, the other approach would be less cluttered if more values are going to be stored) that uses less program mem, but more var mem
Sketch uses 11962 bytes (37%) of program storage space. Maximum is 32256 bytes.
Global variables use 495 bytes (24%) of dynamic memory, leaving 1553 bytes for local variables. Maximum is 2048 bytes.


Val0 is new value. Val1 is highest recorded value, Val2 next highest, etc.
Buffer nodes store highest values seen.
The row of watch nodes at the bottom are your stored data.

Rather than try to determine which buffers should be pulsed to update we just push the same value into the buffer if it is not supposed to update.

For each new value, lowest row of if-else only apply if Val0>Val1 (new highest value): Shift all values, pushing new value into Val1. Defer nodes after buffer allow us to loop the value back up, but they also postpone updates until all buffer nodes update (so we don’t for example read Val0 into 1st buffer, then copy it to all the other buffers instead of shifting existing values).

The next row of if-else are ignored if Val0>Val1, but used if Val0>Val2 (new value is 2nd highest value seen). Push Val0 into 2nd buffer and shift the rest of the values into next buffers.

Process repeats for each row of if-else, with one less if-else node needed for each row.

NOTE: if Val0 is updated when Stop pulse is made, you probably want a defer node before sending it to buffer nodes to make sure if-else nodes have refreshed before updating buffers.