From: Martin DeMello Date: 2011-05-15T06:30:33+09:00 Subject: Re: search nearest to elements in array (hash) On Sun, May 15, 2011 at 2:35 AM, Mateus .. wrote: > Hi! > > I'm interesting, what is the best way to find nearest element in array > in comparison with "needle"? Depends - if there's a comparison function, and your array is sorted on it, then just do a binary search. If not, there's nothing better than a linear search, calculating the distance between each element and the needle. martin