title: Sort values of matrix in python
body: <p>What I have so far is:</p>
  
  <pre><code>dict={'A':[1,2,3], 'B':[2,5,4], 'C':[2,1,8]}
  N=len(keys)
  m=numpy.zeros(N,N)
  for i in range(N):
      for j in range(N):
           m[i-1,j-1]=covariance(values[i-1],values[j-1])
           m[j-1,i-1]=covariance(values[j-1],values[i-1])
  m=numpy.triu(m)
  </code></pre>
  
  <p>which gives me:</p>
  
  <pre><code>1   0.639  0.07
  0     1    0.51
  0     0      1
  </code></pre>
  
  <p>I dont have the column names or the row names yet. I would like something like this:</p>
  
  <pre><code>       A     B      C
  A      1   0.639  0.07
  B      0     1    0.51
  C      0     0      1
  </code></pre>
  
  <p>Given this matrix, I would like to sort it in descending order by the value of the matrix so the output I would like is:</p>
  
  <pre><code>A &amp; A: 1
  B &amp; B: 1
  C &amp; C: 1
  A &amp; B: 0.639
  B &amp; C: 0.51
  A &amp; C: 0.07
  B &amp; A: 0 #etc
  </code></pre>
  
  <p>From the output would like to save it into a csv file where the first column are the names and the second column are the corresponding scores </p>
  
  <p>Thanks for reading. </p>