gsort — decreasing order sorting
[s, [k]]=gsort(v ) [s, [k]]=gsort(v,flag1) [s, [k]]=gsort(v,flag1,flag2)
real, integer or character string vector/matrix.
a string 'r', 'c','g','lr' and 'lc'.
a string 'i' for increasing and 'd' for decreasing order. k : vector or matrix of integers
gsort is similar to sort with additional properties.
The third argument can be used to chose between increasing or
decreasing order. The second argument can be used for lexical orders.
[s,k]=gsort(a,'g') and [s,k]=gsort(a,'g','d') are the
same as [s,k]=gsort(a). They perform a sort of the entries of
matrix a, a being seen as the stacked vector a(:)
(columnwise). [s,k]=gsort(a,'g','i') performs the same
operation but in increasing order.
[s,k]=gsort(a,'lr') sort the rows of the matrix a
in lexical decreasing order. s is obtained by a permutation
of the rows of matrix a given by the column vector k)
in such a way that the rows of s verify s(i,:) > s(j,:) if
i<j. [s,k]=gsort(a,'lr','i') performs the same operation
for increasing lexical order
[s,k]=gsort(a,'lc') sort the columns of the matrix a
in lexical decreasing order. s is obtained by a permutation
of the columns of matrix int(a) (or a) given by the row vector k)
in such a way that the columns of s verify s(:,i) > s(:,j) if
i<j. [s,k]=gsort(a,'lc','i') performs the same operation
for increasing lexical order
alr=[1,2,2;
1,2,1;
1,1,2;
1,1,1];
[alr1,k]=gsort(alr,'lr','i')
[alr1,k]=gsort(alr,'lc','i')
v=int32(alr)
gsort(v)
gsort(v,'lr','i')
gsort(v,'lc','i')
v=['Scilab' '2.6'
'Scilab' '2.7'
'Scicos' '2.7'
'Scilab' '3.1'
'Scicos' '3.1'
'Scicos' '4.0'
'Scilab' '4.0']
gsort(v,'lr','i')
gsort(v,'lc','i')