I am trying to create a custom sort for a vector of class pointers by using a sort predicate:
struct sort_by_airtime                                                                                            
{                                                                                                                 
    inline bool operator() (const Network *n1, const Network *n2)                                                 
    {                                                                                                             
      return (n1->airtime() < n2->airtime());                                                                     
    }                                                                                                             
};      
For each network, we sort by a float returned by airtime().
Now, I try to use this as follows:
std::vector<Network *> Simulator::sort_networks(std::vector<Network *> netlist, bool sort_airtime) {
  std::vector<Network *> new_netlist = netlist;
  if(sort_airtime) {
    sort(new_netlist.begin(), new_netlist.end(), sort_by_airtime());
  }
}
However, I get a lot of errors like this:
In file included from Simulator.cpp:7:
Simulator.h: In member function ‘bool Simulator::sort_by_airtime::operator()(const Network*, const Network*)’:
Simulator.h:48: error: passing ‘const Network’ as ‘this’ argument of ‘virtual float Network::airtime()’ discards qualifiers
Simulator.h:48: error: passing ‘const Network’ as ‘this’ argument of ‘virtual float Network::airtime()’ discards qualifiers
Am I not specifying the argument passed to the predicate properly? airtime() is implemented by classes that inherit the Network class.