Sort by distance

Fixes #332
Consistency