1 function [carray, order]=sortlengths(carray);
\r
2 %EXT2INT Input arguments:
\r
3 % 1) cell (char) array
\r
5 % Sorts the cell array with respect to element length.
\r
6 % Returns the sorted array and the corresponding index mapping.
\r
8 % Toolbox for nonlinear filtering.
\r
9 % Copyright (C) 2005 Jakob Rosén <jakob.rosen@gmail.com>
\r
11 % This program is free software; you can redistribute it and/or
\r
12 % modify it under the terms of the GNU General Public License
\r
13 % as published by the Free Software Foundation; either version 2
\r
14 % of the License, or (at your option) any later version.
\r
16 % This program is distributed in the hope that it will be useful,
\r
17 % but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
18 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
19 % GNU General Public License for more details.
\r
21 % You should have received a copy of the GNU General Public License
\r
22 % along with this program; if not, write to the Free Software
\r
23 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
26 order=cumsum(ones(1,len));
\r
28 % Prepare for BUBBLESORT
\r
31 if length(carray{j})>length(carray{j+1})
\r
33 carray{j}=carray{j+1};
\r
36 order(j)=order(j+1);
\r