Added quick sort (for sorting distances)