"BCC" <bryan@akanta.com> wrote in message
news:pGXLc.622$AY5.226@newssvr21.news.prodigy.com. ..[color=blue]
> Hi,
>
> I'm looking for some way to do a multiple sort on a vector of objects[/color]
based[color=blue]
> on the contents of the objects. For example if my vector is of these
> objects:
>
> class MyClass
> {
> public:
> double value1;
> double value2;
> double value3;
> };
>
> So I would want to sort by each value in combination...
>
> Is there an existing function to do this already somewhere?[/color]
There is ('std::sort', declared by <algorithm>), but you need
to help. Define appropriate comparison operators ('operator<()'),
each of which you pass as an argument to 'std::sort'.
[color=blue]
> Do I need to
> roll my own?[/color]
Only part of it.
[color=blue]
> Any suggestions for the fastest algorithm to use for this[/color]
I'd use 'std::sort', and only pursue other options if it
proved insufficient.
[color=blue]
> (websites or books)?[/color]
www.josuttis.com/libbook
-Mike