title: How to stop std::set from sorting?
body: <p>I have an array of names, but I require only the unique ones. I use <code>std::set</code> so that it clears out duplicate. Yet I need the name appear <strong>in the same order as input</strong>. That means if my input is:</p>
  
  <pre><code>Mary
  Mary
  John
  John
  John
  Apple
  Apple
  Apple
  </code></pre>
  
  <p>[Edit]: After checking comments/answers, I want to emphasis that <em>each name appears in group and does not show up later on in the input</em>. Refer to example, <code>Mary</code> appears two times and that is. It does not show up again later on.[/Edit]</p>
  
  <p>I want my output to be:</p>
  
  <pre><code>Mary
  John
  Apple
  </code></pre>
  
  <p>Using <code>std::set</code>, I get the sorted one:</p>
  
  <pre><code>Apple
  John
  Mary
  </code></pre>
  
  <p>I find out there is <code>unordered_set</code> (from {<a href="http://www.cplusplus.com/reference/unordered_set/unordered_set/" rel="nofollow noreferrer">cplusplus.com</a>}). This one again does <strong>not</strong> keep the input order.</p>
  
  <p>Question:</p>
  
  <ol>
  <li>Is there a way to stop the <code>std::set</code> from sorting?</li>
  <li>I have read that {<a href="https://stackoverflow.com/questions/19979212/stl-set-custom-sort">one can write own's sorting method for <code>std::set</code></a>}. Now if I cannot stop the <code>set</code> from sorting, how about writing my own sorting method, but always return the first element of input as the smallest? (If I can get thru the detail on how to do it...)</li>
  <li>Or is there other thing in <code>std</code> that can reduce a group of strings into a unique set, but does not sort it?</li>
  </ol>
  
  <p>Thanks!</p>