sort STL lists

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hagen

    sort STL lists

    Hello,

    got a short question about the sort algorithm of the list container in the
    Standard Template Library:

    Can I use the sort algorithm with another parameter to sort by? Sort uses
    the operator< of the elements it consists of to sort the list. Now I´m
    interested to sort the elements by another < relation (I´m dealing with
    multivariate polynomials). Do I have to change the operator to sort the way
    it is most often needed and have to sort by hand for the less often cases or
    is there a way to tell sort by which relation it should sort the list?

    Thank you, Greetings, Hagen.


  • Moonlit

    #2
    Re: sort STL lists

    Hi

    Yes, You can use a functor for the sort.

    It is an object with the '()' overloaded.


    Look at http://www.sgi.com/tech/stl for details

    Regards, Ron AF Greve.


    "Hagen" <hal22@t-online.de> wrote in message
    news:bpjflv$3b6 $00$1@news.t-online.com...[color=blue]
    > Hello,
    >
    > got a short question about the sort algorithm of the list container in the
    > Standard Template Library:
    >
    > Can I use the sort algorithm with another parameter to sort by? Sort uses
    > the operator< of the elements it consists of to sort the list. Now I´m
    > interested to sort the elements by another < relation (I´m dealing with
    > multivariate polynomials). Do I have to change the operator to sort the[/color]
    way[color=blue]
    > it is most often needed and have to sort by hand for the less often cases[/color]
    or[color=blue]
    > is there a way to tell sort by which relation it should sort the list?
    >
    > Thank you, Greetings, Hagen.
    >
    >[/color]


    Comment

    Working...