Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!19g2000hsx.googlegroups.com!not-for-mail
From:  "G.A.M." <x0Zero@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to sort cell array of cell arrays by inner value
Date: Thu, 11 Oct 2007 03:31:57 -0000
Organization: http://groups.google.com
Lines: 38
Message-ID: <1192073517.687686.113540@19g2000hsx.googlegroups.com>
References: <1191983851.468137.61110@r29g2000hsg.googlegroups.com>
NNTP-Posting-Host: 76.122.60.107
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Trace: posting.google.com 1192073517 3152 127.0.0.1 (11 Oct 2007 03:31:57 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 11 Oct 2007 03:31:57 +0000 (UTC)
In-Reply-To: <feho22$2kd$1@canopus.cc.umanitoba.ca>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: 19g2000hsx.googlegroups.com; posting-host=76.122.60.107;
Xref: news.mathworks.com comp.soft-sys.matlab:432345



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. What is the
> >best way to do this? Thanks
>
> Use cellfun to extract just the value to be sorted on into an
> array. Sort that array, using the two-output sort so that
> you get the indices. Then index the original cell array at that
> index list.
>
> --
>    "Okay, buzzwords only. Two syllables, tops."  -- Laurie Anderson

I appreciate the guidance. However, it looks like I need an example
because I can't figure out the cellfun part. 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

A simple example of how to apply the advice given above would be most
helpful. Thanks.