STL sort on arrays of pointers

From: Der Andere (matieuloeschmich_at_gmx.net)
Date: 04/30/04


Date: Fri, 30 Apr 2004 01:34:33 +0200

I have an array of pointers (to a class) which I want to have sorted. I have
implemented the < operator for the class but I guess STL sort will sort the
pointers according to _their_ values (the addresses). Or will it work as I
intended? Do you know ways to circumvent the problem?

Thanks,
Matthias

--
Für emails Anweisung in der Adresse befolgen


Relevant Pages

  • Re: Sorting records using sort()
    ... > Is there an easy way to call STL sort() on this data and sort it. ... > The data is big and I do NOT want to allocate a list of pointers ... C routine qsort will do this. ... (It takes two void*'s as args). ...
    (comp.lang.cpp)
  • Re: STL sort on arrays of pointers
    ... > I have an array of pointers which I want to have sorted. ... > implemented the < operator for the class but I guess STL sort will sort the ... std::sort can be given a custom comparison function. ...
    (comp.lang.cpp)
  • Re: Differance between Array and Pointers
    ... Well, except that arrays tend to be much larger than pointers, and the ... An array is a contiguous region of memory containing N elements of M ... indexing vs. a loop). ...
    (comp.arch.embedded)
  • [RFCv2][PATCH] flexible array implementation
    ... I call it a flexible array. ... storage for pointers to the second level. ... all locking must be provided by the caller. ... make sure to pass in &ptr instead of ptr. ...
    (Linux-Kernel)
  • [RFC][PATCH] flexible array implementation v4
    ... I call it a flexible array. ... so never does an order>0 allocation. ... storage for pointers to the second level. ... all locking must be provided by the caller. ...
    (Linux-Kernel)