sort STL lists

Discussion in 'C++' started by Hagen, Nov 20, 2003.

  1. Hagen

    Hagen Guest

    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.
    Hagen, Nov 20, 2003
    #1
    1. Advertising

  2. Hagen

    Moonlit Guest

    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" <> wrote in message
    news:bpjflv$3b6$00$-online.com...
    > 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, Nov 20, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JustSomeGuy

    Sorting lists of lists...

    JustSomeGuy, Jun 17, 2004, in forum: C++
    Replies:
    0
    Views:
    305
    JustSomeGuy
    Jun 17, 2004
  2. Jon Slaughter

    lists of lists

    Jon Slaughter, Dec 13, 2004, in forum: C++
    Replies:
    4
    Views:
    405
    Buster
    Dec 13, 2004
  3. =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==

    List of lists of lists of lists...

    =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==, May 8, 2006, in forum: Python
    Replies:
    5
    Views:
    384
    =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==
    May 15, 2006
  4. Bit byte
    Replies:
    2
    Views:
    297
    Victor Bazarov
    Apr 6, 2006
  5. Navin
    Replies:
    1
    Views:
    670
    Ken Schaefer
    Sep 9, 2003
Loading...

Share This Page