<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE MAN SYSTEM "../../manrev.dtd">
<MAN>
  <LANGUAGE>eng</LANGUAGE>
  <TITLE>lex_sort</TITLE>
  <TYPE>Scilab Function</TYPE>
  <DATE>April 1999</DATE>
  <SHORT_DESCRIPTION name="lex_sort"> lexicographic matrix rows  sorting</SHORT_DESCRIPTION>
  <CALLING_SEQUENCE>
    <CALLING_SEQUENCE_ITEM>[N, [k]]=lex_sort(M [,sel] [,'unique'])  </CALLING_SEQUENCE_ITEM>
    <CALLING_SEQUENCE_ITEM>  </CALLING_SEQUENCE_ITEM>
  </CALLING_SEQUENCE>
  <PARAM>
    <PARAM_INDENT>
      <PARAM_ITEM>
        <PARAM_NAME>M</PARAM_NAME>
        <PARAM_DESCRIPTION>
          <SP>: real matrix</SP>
        </PARAM_DESCRIPTION>
      </PARAM_ITEM>
      <PARAM_ITEM>
        <PARAM_NAME>N</PARAM_NAME>
        <PARAM_DESCRIPTION>
          <SP>: real  matrix</SP>
        </PARAM_DESCRIPTION>
      </PARAM_ITEM>
      <PARAM_ITEM>
        <PARAM_NAME>k</PARAM_NAME>
        <PARAM_DESCRIPTION>
          <SP>: column vector  of integers</SP>
        </PARAM_DESCRIPTION>
      </PARAM_ITEM>
    </PARAM_INDENT>
  </PARAM>
  <DESCRIPTION>
    <P><VERB>N=lex_sort(M)</VERB> sorts the rows (as a group) of the matrix <VERB>M</VERB>
    in ascending order. If required the output argument <VERB>k</VERB> contains
    the ordering: <VERB>[N,k]=lex_sort(M)</VERB> returns <VERB>k</VERB>  such as <VERB>N</VERB>  is
    uequal to <VERB>M(k,:)</VERB> .</P>
    <P><VERB>N=lex_sort(M,sel [,'unique'])</VERB> produces the  same result as the
    following sequence of instructions:</P>
    <VERBATIM>
<![CDATA[
[N,k]=lex_sort(M(:,sel) [,'unique']);
N=M(k,:)
   ]]>
    </VERBATIM>
    <P>
    The <VERB>'unique'</VERB> flag has to be given if one wants to retain only
    unique rows in the result. Note that <VERB>lex_sort(M,sel,'unique')</VERB>
    retains only rows such that M(:,sel) are unique.</P>
  </DESCRIPTION>
  <EXAMPLE>
<![CDATA[
M=round(2*rand(20,3));

lex_sort(M)
lex_sort(M,'unique')
[N,k]=lex_sort(M,[1 3],'unique')

 ]]>
  </EXAMPLE>
  <SEE_ALSO>
    <SEE_ALSO_ITEM>
      <LINK>sort</LINK>
    </SEE_ALSO_ITEM>
  </SEE_ALSO>
</MAN>
