order the dist matrix with respect to clustering