title: What is the fastest way to get a vector of sorted unique values from a data.table?
body: <p>The <a href="https://stackoverflow.com/a/36949148/3817004">answer</a> to this <a href="https://stackoverflow.com/questions/36936613/unique-sorted-rows-single-column-from-r-data-table%20Unique%20sorted%20rows%20single%20column%20from%20R%20data.table">question (Unique sorted rows single column from R data.table)</a> suggested three different ways to get a vector of sorted unique values from a <code>data.table</code>:</p>
  
  <pre><code># 1
  sort(salesdt[, unique(company)])
  #2 
  sort(unique(salesdt$company))
  #3
  salesdt[order(company), unique(company)]
  </code></pre>
  
  <p>Another <a href="https://stackoverflow.com/a/36951561/3817004">answer</a> suggested other sort options than lexicographical order:</p>
  
  <pre><code>salesdt[, .N, by = company][order(-N), company]
  salesdt[, sum(sales), by = company][order(-V1), company]
  </code></pre>
  
  <p>The <code>data.table</code> was created by</p>
  
  <pre><code>library(data.table)
  company &lt;- c("A", "S", "W", "L", "T", "T", "W", "A", "T", "W")
  item &lt;- c("Thingy", "Thingy", "Widget", "Thingy", "Grommit", 
            "Thingy", "Grommit", "Thingy", "Widget", "Thingy")
  sales &lt;- c(120, 140, 160, 180, 200, 120, 140, 160, 180, 200)
  salesdt &lt;- data.table(company,item,sales) 
  </code></pre>
  
  <p>As always, if different options are available to choose from I started to wonder what the best solution would be, in particular if the <code>data.table</code> would be much larger. I have searched a bit on SO but haven't found a particular answer so far.</p>