Sort by whitelist match then distance

Fixes #318