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

*To*: mathgroup at smc.vnet.net*Subject*: [mg113817] Re: Sort a List, in a List of Lists of Lists*From*: Tomas Garza <tgarza10 at msn.com>*Date*: Sun, 14 Nov 2010 06:09:11 -0500 (EST)

A quick shot: In[1]:== 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}}}; In[2]:== b=={{{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}}}; In[3]:== c==Sort/@Sort/@#&/@a Out[3]== {{{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}}} In[4]:== b====c Out[4]== True -Tomas > Date: Sat, 13 Nov 2010 00:59:27 -0500 > From: leigh.pascoe at inserm.fr > Subject: [mg113797] Sort a List, in a List of Lists of Lists > To: mathgroup at smc.vnet.net > > 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}}} > > i.e retaining the same structure with the paired elements in the > original order. I can't seem to get the syntax right to do this apart > from the obvious > > {{Sort[{1, 2}], Sort[{2, 1}], Sort[{1, 1}]}, {Sort[{1, 1}], > Sort[{1, 1}], Sort[{1, 2}]}, {Sort[{2, 1}], Sort[{2, 2}], > Sort[{1, 2}]}, {Sort[{2, 2}], Sort[{1, 2}], > Sort[{2, 2}]}, {Sort[{1, 1}], Sort[{2, 1}], > Sort[{1, 2}]}, {Sort[{1, 2}], Sort[{2, 2}], Sort[{2, 2}]}} > > I must have a blind spot for the correct command. Can someone please > help me with what should be a straightforward sort. As I want to carry > this out on several hundred thousand pairs I need a more efficient > command. Thanks in advance. > > LP > > ---------------------------------------------------------------- > This message was sent using IMP, the Internet Messaging Program. > > >