title: What's the most efficient way to erase duplicates and sort a vector?
body: <p>I need to take a C++ vector with potentially a lot of elements, erase duplicates, and sort it.</p>
  
  <p>I currently have the below code, but it doesn't work.</p>
  
  <pre><code>vec.erase(
        std::unique(vec.begin(), vec.end()),
        vec.end());
  std::sort(vec.begin(), vec.end());
  </code></pre>
  
  <p>How can I correctly do this?</p>
  
  <p>Additionally, is it faster to erase the duplicates first (similar to coded above) or perform the sort first?  If I do perform the sort first, is it guaranteed to remain sorted after <code>std::unique</code> is executed?</p>
  
  <p>Or is there another (perhaps more efficient) way to do all this?  </p>