nearest number in a list


hello:

i need find in number list nearest number.

for example:

mylist=[140,76,12,-52,-116,-180,-244,-306,-371,-436,-502,-564,-628,-693,-756]

i need find nearest number of example, -200

 

can me please?

many thanks

mylist=[140,76,12,-52,-116,-180,-244,-306,-371,-436,-502,-564,-628,-69, 3,-756]

 

sortedlist = mylist.duplicate()

sortedlist.sort()

put sortedlist

-- [-756, -628, -564, -502, -436, -371, -306, -244, -180, -116, -69, -52, 3, 12, 76, 140]

 

vindex = sortedlist.findposnear(-200) -- 9

 

put sortedlist[vindex]

-- -180



More discussions in Director Lingo


adobe

Comments

Popular posts from this blog

How to set the order of FAQs instead of alphabetical

Thread: Get UK Keyboard working

how do I change the e-mail address for my merchant account