sort by distance instead of naive variation detection