bool sorter(const ri_ptr & lhs, const ri_ptr & rhs) { // if equal scores, prefer item with higher preference // usually this indicates network reliability or user-configured preference if( lhs->score() == rhs->score() ) { return lhs->preference() > rhs->preference(); } return lhs->score() > rhs->score(); }