store 2 values in std::vector

Hi,
I need to store x & y coordinates of point(of type double) in arraylist, then I have to sort this with respect to values of x.
I hope so I am clear.

std::vector<double> arr;
arr.push_back(x1,y1);
arr.push_back(x2,y2);
arr.push_back(x3,y3);
std::sort(arr.begin(), arr.end()); // only w.r.t values of x

Please help
Thanks alot
I have one more problem,

std::sort(arr.begin(), arr.end());
std::reverse(arr.begin(), arr.end());

my list now shows(in increasing order of values of y)
eg:
(27.98,9.045)
(26.98,9.045)
(27.51,9.045)
(16.14,22.14)


I changed the structure, I want w.r.t y

struct pointt
{
pointt(double _x, double _y) : x(_x), y(_y) {}
bool operator < (const pointt &p) const {return (p.y < y);}
bool operator > (const pointt &p) const {return (p.y > y);}
double x, y;
};
Now My requirement is like this
for the same value of y, I have to arrange x in increasing order
from above list I want
(26.98,9.045)
(27.51,9.045)
(27.98,9.045)
(16.14,22.14)
only for the same value of y, I have to arrange x in increasing order
Thanks
Last edited on
Topic archived. No new replies allowed.