find nearest location from original point
<p>Suppose we have the following problem. We want to read a set of (x, y) coordinates and a name, then sort them in order increasing distance from the origin (0, 0).here is algorithm which use simplest buble sort</p>

<pre><code> #include&lt;iostream&gt;
    #include &lt;algorithm&gt;
    using namespace std;
    struct point{
        float x;
        float y;
         char name[20];

         };
      float dist(point p){
          return p.x*p.x+p.y*p.y;
            }
       void sorting(point pt[],int n){
          bool doMore = true;
        while (doMore) {
            doMore = false;  // Assume no more passes unless exchange made.
            for (int i=0; i&lt;n-1; i++) {
                if (dist(pt[i]) &gt; dist(pt[i+1])) {
                    // Exchange elements
                    point temp = pt[i]; pt[i] = pt[i+1]; pt[i+1] = temp;
                    doMore = true;  // Exchange requires another pass.
                }
            }
        }

       }
       void display(point pt[],int n){
            for (int i=0;i&lt;n;i++){
                cout&lt;&lt;pt[i].name&lt;&lt; " ";
                   }
       }
    int main(){
    point pts[1000];
    int n=0;

    while (cin&gt;&gt;pts[n].name&gt;&gt;pts[n].x&gt;&gt;pts[n].y){
        n++;

    }
     sorting(pts,n);
     display(pts,n);

    return 0;
    }
</code></pre>

<p>but i want to write STL sorting algorithm instead of buble sort and how  to do such?i mean that how use dist function in STL sort algorithm
thanks</p>
