<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE MAN SYSTEM "../../manrev.dtd">
<MAN>
  <LANGUAGE>eng</LANGUAGE>
  <TITLE>gsort</TITLE>
  <TYPE>Scilab Function</TYPE>
  <DATE>April 1993</DATE>
  <SHORT_DESCRIPTION name="gsort"> decreasing order sorting</SHORT_DESCRIPTION>
  <CALLING_SEQUENCE>
    <CALLING_SEQUENCE_ITEM>[s, [k]]=gsort(v )  </CALLING_SEQUENCE_ITEM>
    <CALLING_SEQUENCE_ITEM>[s, [k]]=gsort(v,flag1)  </CALLING_SEQUENCE_ITEM>
    <CALLING_SEQUENCE_ITEM>[s, [k]]=gsort(v,flag1,flag2)  </CALLING_SEQUENCE_ITEM>
  </CALLING_SEQUENCE>
  <PARAM>
    <PARAM_INDENT>
      <PARAM_ITEM>
        <PARAM_NAME>v,s</PARAM_NAME>
        <PARAM_DESCRIPTION>
          <SP>: real vector/matrix; character string vector/matrix</SP>
        </PARAM_DESCRIPTION>
      </PARAM_ITEM>
      <PARAM_ITEM>
        <PARAM_NAME>flag1</PARAM_NAME>
        <PARAM_DESCRIPTION>
          <SP>: a string <VERB>'r'</VERB>, <VERB>'c'</VERB>,<VERB>'g'</VERB>,<VERB>'lr'</VERB> and <VERB>'lc'</VERB>.</SP>
        </PARAM_DESCRIPTION>
      </PARAM_ITEM>
      <PARAM_ITEM>
        <PARAM_NAME>flag2</PARAM_NAME>
        <PARAM_DESCRIPTION>
          <SP>: a string <VERB>'i'</VERB> for increasing and <VERB>'d'</VERB> for decreasing order. k : vector or matrix of integers</SP>
        </PARAM_DESCRIPTION>
      </PARAM_ITEM>
    </PARAM_INDENT>
  </PARAM>
  <DESCRIPTION>
    <P><VERB>gsort</VERB> is similar to <VERB>sort</VERB> 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.</P>
    <P><VERB>[s,k]=gsort(a,'g')</VERB> and <VERB>[s,k]=gsort(a,'g','d')</VERB> are  the
    same as <VERB>[s,k]=gsort(a)</VERB>. They perform a sort of the entries of 
    matrix <VERB>a</VERB>, <VERB>a</VERB> being seen as the stacked vector <VERB>a(:)</VERB>
    (columnwise). <VERB>[s,k]=gsort(a,'g','i')</VERB> performs the same 
    operation but in increasing order.</P>
    <P><VERB>[s,k]=gsort(a,'lr')</VERB> sort the rows of the matrix <VERB>int(a)</VERB> 
    ( if <VERB>a</VERB> is a real matrix) or <VERB>a</VERB> (if <VERB>a</VERB> is a
    character string matrix)
    in lexical decreasing order. <VERB>s</VERB> is obtained by a permutation 
    of the rows of matrix <VERB>int(a)</VERB> (or <VERB>a</VERB>) given by the column vector <VERB>k</VERB>)
    in such a way that the rows of <VERB>s</VERB> verify <VERB>s(i,:) &gt; s(j,:)</VERB> if
    <VERB>i&lt;j</VERB>. <VERB>[s,k]=gsort(a,'lr','i')</VERB> performs the same operation 
    for increasing lexical order</P>
    <P><VERB>[s,k]=gsort(a,'lc')</VERB> sort the columns of the matrix <VERB>int(a)</VERB> 
    ( if <VERB>a</VERB> is a real matrix) or <VERB>a</VERB> (if <VERB>a</VERB> is a
    character string matrix)
    in lexical decreasing order. <VERB>s</VERB> is obtained by a permutation 
    of the columns of matrix <VERB>int(a)</VERB> (or <VERB>a</VERB>) given by the row vector <VERB>k</VERB>)
    in such a way that the columns of <VERB>s</VERB> verify <VERB>s(:,i) &gt; s(:,j)</VERB> if
    <VERB>i&lt;j</VERB>. <VERB>[s,k]=gsort(a,'lc','i')</VERB> performs the same operation 
    for increasing lexical order</P>
  </DESCRIPTION>
  <EXAMPLE>
<![CDATA[
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')
 ]]>
  </EXAMPLE>
  <SEE_ALSO>
    <SEE_ALSO_ITEM>
      <LINK>find</LINK>
    </SEE_ALSO_ITEM>
  </SEE_ALSO>
</MAN>
