+template<typename T, unsigned N>
+void sort_points(SurfacePoint<T, N> *points, unsigned size)
+{
+ for(unsigned i=0; i<size; ++i)
+ {
+ unsigned n = i;
+ for(unsigned j=i+1; j<size; ++j)
+ if(points[j].distance<points[n].distance)
+ n = j;
+ if(n!=i)
+ std::swap(points[i], points[n]);
+ }
+}
+