Octave - Sorting a Matrix

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

For example, if my matrix data is:

 1     3  5     7 -1     4 

Then the desired output (sorting by the first column) would be:

-1     4  1     3  5     7 

But the output of sort(data) is:

-1     3  1     4  5     7 

How can I sort this matrix by the first column?

Replay

I think the sortrows function is what you're looking for.

>> sortrows(data,1)

ans =

    -1     4
     1     3
     5     7

Category: matlab Time: 2008-09-25 Views: 2

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.210 (s). 12 q(s)