[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Sorting a structure array
From: |
Daniel Arteaga |
Subject: |
Sorting a structure array |
Date: |
Fri, 18 Feb 2011 13:25:37 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; ca-ES; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 |
Hi,
I need to sort a structure array, which contains other structure array
as a field, according to a given field of the substructure.
The following (silly) example will clarify:
s(1).t(1).name="giraffe"
s(2).t(1).name="lion"
s(3).t(1).name="gorilla"
s(1).t(2).name="tree"
s(2).t(2).name="bush"
s(3).t(2).name="plant"
I need to sort s according to the values of s(:).t(1).name (so,
according to the name of the animals). I would expect the now order to
be s(1) s(3) s(2).
I have tried converting to cell array, with the deal function... no
success so far.
Any help will be appreciated.
Daniel
- Sorting a structure array,
Daniel Arteaga <=