Added an option to sort the result set by min distance