Path: news.mathworks.com!newsfeed-00.mathworks.com!NNTP.WPI.EDU!elk.ncren.net!newsflash.concordia.ca!canopus.cc.umanitoba.ca!not-for-mail
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to sort cell array of cell arrays by inner value
Date: Thu, 11 Oct 2007 03:37:30 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 30
Message-ID: <fek5pq$qi8$1@canopus.cc.umanitoba.ca>
References: <1191983851.468137.61110@r29g2000hsg.googlegroups.com> <feho22$2kd$1@canopus.cc.umanitoba.ca> <1192073517.687686.113540@19g2000hsx.googlegroups.com>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1192073850 27208 192.70.172.160 (11 Oct 2007 03:37:30 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Thu, 11 Oct 2007 03:37:30 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:432348



In article <1192073517.687686.113540@19g2000hsx.googlegroups.com>,
G.A.M. <x0Zero@gmail.com> wrote:
>On Oct 10, 1:30 am, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
>wrote:
>> In article <1191983851.468137.61...@r29g2000hsg.googlegroups.com>,

>> G.A.M. <x0Z...@gmail.com> wrote:
>> >I have a 1 x 500 cell array where each cell is a 1 x 4 cell array. The
>> >inner 1 x 4 cell array has a double numeric value in the 4th cell. I
>> >would like to sort the 500 cells by this numeric value.

>Here's some sample data.
>I want to sort AA by the numeric values in the 4th column of the inner
>cells.

a = {'ay', 'd1', {'iala', 'lbb'}, 4}
b = {'xi', 'a2', {'adoa', 'bab'}, 7}
c = {'um', 'e3', {'caaa', 'cyb'}, 3}
d = {'iw', '4t', {'ljik', 'lwb'}, 9}
AA = {b, a, c, d}

>This is how I'm indexing into the numeric values I want to use for
>sorting:
>AA{1}{4}
>ans = 7

[vals,order] = cellfun(@(v) v{4},AA);
sortedAA = AA(order);
-- 
   "History is a pile of debris"                     -- Laurie Anderson