Add an experimental distance ranking algorithm

Connected with issue #180