Closed argument list in sortdistances function