Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.4.1 - English

Change language to:
Français - 日本語 - Português - Русский

Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
However, this page did not exist in the previous stable version.

Scilab help >> Elementary Functions > Search and sort > lex_sort

lex_sort

lexicographic matrix rows sorting

Calling Sequence

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

Arguments

M

real matrix

N

real matrix

k

column vector of integers

Description

the lex_sort function is now obsolete. It can be replaced by functions gsort and unique.

N=lex_sort(M) sorts the rows (as a group) of the matrix M in ascending order. If required the output argument k contains the ordering: [N,k]=lex_sort(M) returns k such as N is equal to M(k,:) .

N=lex_sort(M,sel [,'unique']) produces the same result as the following sequence of instructions:

[N,k]=lex_sort(M(:,sel) [,'unique']);
N=M(k,:)

The 'unique' flag has to be given if one wants to retain only unique rows in the result. Note that lex_sort(M,sel,'unique') retains only rows such that M(:,sel) are unique.

Examples

M=round(2*rand(20,3));

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

See Also

  • gsort — sorting by quick sort algorithm
  • unique — extract unique components of a vector or matrices
Report an issue
<< gsort Search and sort vectorfind >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Apr 02 17:36:21 CEST 2013