Re: Sort a List, in a List of Lists of Lists

• To: mathgroup at smc.vnet.net
• Subject: [mg113821] Re: Sort a List, in a List of Lists of Lists
• From: "Nasser M. Abbasi" <nma at 12000.org>
• Date: Sun, 14 Nov 2010 06:09:57 -0500 (EST)
• References: <ibl9g2\$b8a\$1@smc.vnet.net>

```On 11/12/2010 9:59 PM, leigh.pascoe at inserm.fr wrote:
> Dear Mathgroup,
>
> I have a lsit of Lists of Lists:
>
> {{{1,2},{2,1},{1,1}},{{1,1},{1,1},{1,2}},{{2,1},{2,2},{1,2}},{{2,2},{1,2},{2,2}},{{1,1},{2,1},{1,2}},{{1,2},{2,2},{2,2}}}
>
> I would like to sort the elements in the lowest level of brackets to give
>
> {{{1, 2}, {1, 2}, {1, 1}}, {{1, 1}, {1, 1}, {1, 2}}, {{1, 2}, {2,
>      2}, {1, 2}}, {{2, 2}, {1, 2}, {2, 2}}, {{1, 1}, {1, 2}, {1,
>      2}}, {{1, 2}, {2, 2}, {2, 2}}}
>

one way:

------------------
a={{{1,2},{2,1},{1,1}},{{1,1},{1,1},{1,2}},{{2,1},{2,2},{1,2}},{{2,2},{1,2},{2,2}},{{1,1},{2,1},{1,2}},{{1,2},{2,2},{2,2}}};

{nRow,nCol,nPages}=Dimensions[a];
Map[Sort,Flatten[a,1]];
Partition[%, nCol]
------------------

Out[138]= {{{1,2},{1,2},{1,1}},{{1,1},{1,1},{1,2}},{{1,2},{2,2},{1,2}},{{2,2},{1,2},{2,2}},{{1,1},{1,2},{1,2}},{{1,2},{2,2},{2,2}}}

--Nasser

```

• Prev by Date: Re: exporting an array
• Next by Date: Re: Mathematica 8
• Previous by thread: Re: Sort a List, in a List of Lists of Lists
• Next by thread: Re: Sort a List, in a List of Lists of Lists