title: Sorting output of xtable
body: <p>I have a data set with which I create a table, but now I would like the output to be sorted alphabetically. <code>order</code>, <code>sort</code> or <code>sort.list</code> I don't get to work. Here is an example of what I have. </p>
  
  <pre><code>library(maptools)
  data(wrld_simpl)
  tab.test &lt;- xtable(subset(wrld_simpl@data, select=c(NAME, REGION)))
  head(tab.test)
  % latex table generated in R 2.15.1 by xtable 1.7-0 package
  % Sun Nov  4 19:58:19 2012
  \begin{table}[ht]
  \begin{center}
  \begin{tabular}{rll}
    \hline
   &amp; NAME &amp; REGION \\ 
    \hline
  ATG &amp; Antigua and Barbuda &amp;  19 \\ 
  DZA &amp; Algeria &amp;   2 \\ 
  AZE &amp; Azerbaijan &amp; 142 \\ 
  ALB &amp; Albania &amp; 150 \\ 
  ARM &amp; Armenia &amp; 142 \\ 
  AGO &amp; Angola &amp;   2 \\ 
     \hline
  \end{tabular}
  \end{center}
  \end{table}
  </code></pre>
  
  <p>I would like to be able to sort it by <code>NAME</code>, <code>REGION</code> or even the first column, which is <code>ISO3</code> and seems to be the default left column. I appreciate your help, including hints to similar questions (I might have overlooked them during my search for a cure).</p>