Path: news.mathworks.com!not-for-mail
From: Loren Shure <loren.shure@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Sorting a cell array according to another
Date: Mon, 9 Nov 2009 09:24:56 -0500
Organization: The MathWorks
Lines: 26
Message-ID: <MPG.2561f04749e86ebe989a63@news.mathworks.com>
References: <92bcbdae-a733-4aab-81c6-f7f15b418fdc@m16g2000yqc.googlegroups.com> <hd70e6$kf6$1@fred.mathworks.com>
NNTP-Posting-Host: shurel.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1257776696 6821 172.31.57.214 (9 Nov 2009 14:24:56 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 9 Nov 2009 14:24:56 +0000 (UTC)
User-Agent: MicroPlanet-Gravity/2.70.2067
Xref: news.mathworks.com comp.soft-sys.matlab:583550


In article <hd70e6$kf6$1@fred.mathworks.com>, miroslav.nospam@balda.cz 
says...
> steeve_dun <steeve_dun@yahoo.fr> wrote in message <92bcbdae-a733-4aab-81c6-f7f15b418fdc@m16g2000yqc.googlegroups.com>...
> > Hi,
> > I have 2 cell arrays X and Y.
> > I&#8217;ve sorted X with [a idx]=sort(X) and I would like Y to be sorted
> > according to idx.
> > Can anybody help please?
> > Thanks in advance
> 
> Hi,
> 
> try this (for column vectors):
> 
> [xs,idx]=sort(x{:});
> y{:}(idx,:);
> 
> Mira
> 

I think you can also do
y(idx,:) and that should be faster.

-- 
Loren
http://blogs.mathworks.com/loren