sort according to a particular value

Thanks -

So there's no way to do this without having to define

a class/struct? It's just sometimes I only need a

{*filter*} computation like this one time in my code, and having

a separate class for every computation can be overkill.

Is there any way to "get at" the more internal data to use

as a comparison, or is there just not really a way to express

this with STL - so I can do

sort(points.begin(), points.end(), -some fancy expression to sort

based on the first coord of the vector in each element-);

?

Quote:

> struct coords

> {

> float c[3]; // you could use vector<float> here, but

that's

> just needless overhead.

> bool operator<(const coords& rhs) const

> { return c[0] < rhs.c[0]; }

> };

> vector< coords> points;

> --

> Truth,

> James Curran

> http://www.*-*-*.com/

> http://www.*-*-*.com/

Quote:

> > Say I have a vector<vector<float> >, and vectors inside

> > are always size 3 (for instance, I do

> > vector<vector<float> > points;

> > points.resize(25, vector<float>(3))

> > to get 25 points, each with 3 coords.) After storing

> > the values, I want to sort according to the X value

> > only (that is, sort points according to the [0] value of

> > the size-3 vectors inside).

> > Is there an easy way to use sort on this w/o defining a functor

> > class?

Sent via Deja.com http://www.*-*-*.com/

Before you buy.