Consider following comparison function:
bool compare(std::shared_ptr &lhs, std::shared_ptr &rhs){
return lhs->val
In order to access your elements, you need to provide function for strict weak ordering for your type.
std::multiset have the following constructor:
explicit multiset (const key_compare& comp = key_compare(),
const allocator_type& alloc = allocator_type());
As you can see, you can do this by passing comp function pointer (or function object) to the constructor.