kmeans working in parallel, sorting generalized