Q:

Sorting vector of Pointers of Custom Class

I have vector<FPGA*> current_generation_, which I'd like to sort by FPGA member fitness_ using the sort_members function. Applicable code follows:
bool sort_members (FPGA* fpga_first, FPGA* fpga_second) {
    return (fpga_first->fitness() < fpga_second->fitness());
};

fpga.hpp
#include <vector>

class FPGA {
    public:
        explicit FPGA(int input_gates, int output_gates, int normal_gates);

        const int fitness();

    protected:
        int fitness_;
};

fpga.cpp
FPGA::FPGA() {
    this->fitness_ = 0;
}

const int FPGA::fitness() {
    return this->fitness_;
}

implementation:
std::sort(this->current_generation_.begin(), this->current_generation_.end(), sort_members);

errors:
/usr/include/c++/4.9/bits/stl_algo.h: In instantiation of ‘void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::__detail::_Node_iterator<std::pair<const int, FPGA*>, false, false>; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(FPGA*, FPGA*)>]’:
/usr/include/c++/4.9/bits/stl_algo.h:4717:78:   required from ‘void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = std::__detail::_Node_iterator<std::pair<const int, FPGA*>, false, false>; _Compare = bool (*)(FPGA*, FPGA*)]’

/usr/include/c++/4.9/bits/stl_algo.h:1968:22: error: no match for ‘operator-’ (operand types are ‘std::__detail::_Node_iterator<std::pair<const int, FPGA*>, false, false>’ and ‘std::__detail::_Node_iterator<std::pair<const int, FPGA*>, false, false>’)
     std::__lg(__last - __first) * 2,

The remainder of the total error string is huge, but I believe is mostly what the compiler believes(falsely) are candidates. I'm not extremely familiar with c++, and a compiler error of this magnitude and complexity is confusing to me.
I can provide more context if needed. Thanks!
EDIT: A dash.
EDIT EDIT: I screwed up, and was trying to sort the wrong member. Hooray.

A:

The only error that I see is this>current_generation_.end() instead that ->.
In addition you should consider declaring your compare fuction as accepting two const FPGA* instead that just FPGA*. This will force you to declare fitness() as const int fitness() const but it makes sense to have it const.
Mind that since you are using C++11 you can directly use a lambda:
std::sort(data.begin(), data.end(), [](const FPGA* f1, const FPGA* f2) { ... });

You also have the choice to overload operator< directly:
class FPGA {
  ...

  bool operator<(const FPGA* other) const { return fitness_ < other->fitness_; }
}

std::sort(data.begin(), data.end());

This could be useful if it doesn't make sense to have other criteria to compare two FPGA instances since you add some semantics to the object itself.

