Finding next higher and lower numbre in a list

I am new to Grasshoper and have te following problem.
I have a list and want to find the next higher and lower value to a number and extract it to a new list.
Right now I only have a solution for giving me the closest point.

to find the highest you can
reverse the list and take the first value (i=0)
or put -1 as i, it will gave you the last value

1 Like

I basically need the neighbouring numbers

What do you mean by reverse the list? Depending on the given number (here 0.25) it doesn´t always give me the lowest number. So in some case I also have the finde the next smaller number to my given number

I think I quite understand, but your first formulation was not clear. Also I think that abs doesn’t help to give for the following needs.
I think you can sort the list of number, find the number that is closest to you number then take index -1 and index +1 to find the neighbors.
To make a list of index use Series

1 Like


what about something like this?

High low (8.7 KB)


FIND (10.3 KB)

1 Like

I don`t know if I’ve done something wrong, but its nots working for me

Upload your code//

1 Like

No idea where this cluster comes from… (10.9 KB)

1 Like

Sorry my mistake,

here you have the corrected version.

High low (9.0 KB)

1 Like

my mystake, its working. thank you!!