Bugfix: distance sorting