[Scilab-users] sort a table/matrix
Paul Carrico
paul.carrico at free.fr
Sat Nov 10 11:28:50 CET 2012
Dear all,
As it can be done under excel for example, I would like to sort the first
column in increasing order, the each line the same time (see above example).
Does the gsort function allow such rearranging ? or do I've to code it ?
Thanks
Paul
############################################################################
#######
D = [
1 0 3 11 10 13;
4 9 6 -1 -1 0;
17 8 39 9 -451 3;
10 110 -12 1 -9 45 ;
-13 514 15 78 -99 3]
// each line is sorted from the 1rst column (in increasing order)
D_expeted = [
-13 514 15 78 -99 3;
1 0 3 11 10 13;
4 9 6 -1 -1 0;
10 110 -12 1 -9 45;
17 8 39 9 -451 3;
]
// some trials based on an old post . how to use k ?
[g,k] = gsort(D,'c','i')
g2 = gsort(D(:,1),'c','i')
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20121110/f4fe9b3e/attachment.htm>
More information about the users
mailing list