title: A set with custom comparison functor, predictable in case of equality
body: <p>I'm trying to build a <code>std::set</code> with a custom ordering to store "tasks" inside, and I'm wondering wether or not it'll be possible to get what I need with a plain <code>std</code> container.</p>
  
  <p>The set is like:</p>
  
  <pre><code>std::set&lt;Task*, CompareTasks&gt; taskList;
  </code></pre>
  
  <p>And <code>class Task</code> has a public <code>double priority</code> member.</p>
  
  <p>What I need:</p>
  
  <ul>
  <li>EDIT: each task <code>Task *</code> must be unique within the <code>taskList</code></li>
  <li>the tasks must be sorted in decreasing <code>priority</code>.</li>
  <li>if <code>task2</code> happens to share the same <code>priority</code> with <code>task1</code> already in the list, then "<em>first come first served</em>": <code>task2</code> must be inserted <em>after</em> <code>task1</code>.</li>
  </ul>
  
  <p>I tried with the functor:</p>
  
  <pre><code>class CompareTasks
  {
  public:
      bool operator()(Task* const&amp; a, Task* const&amp; b)
      {
          return a-&gt;priority &lt; b-&gt;priority;
      }
  };
  </code></pre>
  
  <p>But tasks I then insert, that have an already recorded <code>priority</code>, are just.. not inserted at all. And I thus suspect that the keys of <code>taskList</code> are the priorities themselves and not the pointer values <code>Task*</code> as written in <code>std::set&lt;Task*, CompareTasks&gt;</code>. How can I check whether it's the case?</p>
  
  <p>More dramatically: Since the ordering must be <strong>weak</strong> in creating comparison functors for <code>std</code> containers, is there any way I'll be able to achieve this with only <code>std::set</code>?</p>