<p>I would like to sort a matrix according to a particular column. There is a <code>sort</code> function, but it sorts all columns independently.</p>

<p>For example, if my matrix <code>data</code> is:</p>

<pre><code> 1     3
 5     7
-1     4
</code></pre>

<p>Then the desired output (sorting by the first column) would be:</p>

<pre><code>-1     4
 1     3
 5     7
</code></pre>

<p>But the output of <code>sort(data)</code> is:</p>

<pre><code>-1     3
 1     4
 5     7
</code></pre>

<p>How can I sort this matrix by the first column?</p>

I think the
sortrows
function is what you're looking for.
```
```
>> sortrows(data,1)

ans =

    -1     4
     1     3
     5     7
```
```