14.24 sortArr

// Function to sort the array of
// points by its distance from P
vector<pair<double,int > > NaoBehavior::sortArr(vector<pair<double, double> > arr,int n, pair<double, double> p)
{
  
    // Vector to store the distance
    // with respective elements
    vector<pair<double,int> > vp;
  
    // Storing the distance with its
    // distance in the vector array
    for (int i = 0; i < n; i++) {
  
        double dist
            = pow((p.first - arr[i].first), 2)
              + pow((p.second - arr[i].second), 2);
  
        vp.push_back(make_pair(dist,i));
    }
  
    // Sorting the array with
    // respect to its distance
    sort(vp.begin(), vp.end());
  
    // Output
    /* for (int i = 0; i < vp.size(); i++) {
        cout << "("
             << vp[i].first << ", "
             << vp[i].second << ") ";
    }
    cout << "\n"; */

    return vp;
}