title: How do you undo a setkey ordering in data.table?
body: <p>Lets say I have a data table DT and I change the ordering with set key</p>
  
  <pre><code>setkey(DT,mykey)
  </code></pre>
  
  <p>Then, maybe I join some things from another table.</p>
  
  <pre><code>DT=DT2[DT]
  </code></pre>
  
  <p>Is there any way to recover my original row ordering? I know, I can do it by explicitly including an index before I use setkey. </p>
  
  <pre><code>N=Nrow(DT)
  DT[,orig_index:=1:N]
  setkey(DT,mykey)
  DT=DT2[DT]
  setkey(DT,orig_index)
  DT[,orig_index:=NULL]
  </code></pre>
  
  <p>Is there a simpler way? If I was doing this with order instead of set key, this would be a little simpler.</p>
  
  <pre><code>o=order(DT$mykey)
  uo=order(o)
  setkey(DT,mykey)
  DT=DT2[DT]
  DT=DT[uo,]
  </code></pre>
  
  <p>It would be kind cool I guess if setkey could be reversed with something like this</p>
  
  <pre><code>setkey(DT,mykey,save.unset=T)
  DT=DT2[DT]
  unsetkey(DT)
  </code></pre>
  
  <p>Here save.unset=T would tell data.table to save the last reordering so it can be reversed.</p>
  
  <p>Better yet, maybe </p>
  
  <pre><code>setkey(DT, reorder=F)
  DT=DT2[DT]
  </code></pre>
  
  <p>This option would tell data.table to use the key ordering for joins or whatever without actually changing the order of DT. Not sure if that is possible or natural to implement. </p>