Mongodb Find for Retrieving the Closest Larger / Closest Smaller Values from a List when there is No Exact Match?

I have a collection with filed memory with values like (1,7,3.5,5) etc with user query parameter for memory contains 2, the query result should be (1,3.5) to nearest matching value.

for More Information please check https://gist.github.com/anandof86/5433086