gilmoreorless/jquery-nearest — pull request #22 by joshpangell (2014-02-10 22:04:32+00:00)
Title: Added an option to sort the result set by min distance

@gilmoreorless's wonderful plugin does a great job of finding the nearest elements. However, I was missing the ability to find the nearest elements sorted in order of proximity nearest to furthest. The current result set it in order of DOM tree. I had posted this as an [issue here](https://github.com/gilmoreorless/jquery-nearest/issues/21), but have gone ahead and made a fix for it instead.

This simple change adds the option `sortMinDist` to receive the result set ordered nearest to furthest. Here is a [fiddle](http://jsfiddle.net/teklocust/nbj3B/4/) to see the update in action.

Usage:
```javascript
$.nearest({
x: e.clientX,
y: e.clientY,
tolerance: 40,
sortMinDist: true
}, '.block');
```