title: Order a matrix by multiple column in r
body: <p>I have a matrix</p>
  
  <pre><code>df&lt;-matrix(data=c(3,7,5,0,1,0,0,0,0,8,0,9), ncol=2)
  rownames(df)&lt;-c("a","b","c","d","e","f")
  
  [,1] [,2]
  a    3    0
  b    7    0
  c    5    0
  d    0    8
  e    1    0
  f    0    9
  </code></pre>
  
  <p>and I would like to order the matrix in descending order first by column 1 and then by column two resulting in the matrix</p>
  
  <pre><code>df.ordered&lt;-matrix(data=c(7,5,3,1,0,0,0,0,0,0,9,8),ncol=2)
  rownames(df.ordered)&lt;-c("b","c","a","e","f","d")
  
     [,1] [,2]
   b    7    0
   c    5    0
   a    3    0
   e    1    0
   f    0    9
   d    0    8
  </code></pre>
  
  <p>Any suggestions on how I could achieve this? Thanks.</p>