Re: when dimension increases
- To: mathgroup at smc.vnet.net
- Subject: [mg67573] Re: [mg67531] when dimension increases
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sat, 1 Jul 2006 05:11:58 -0400 (EDT)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
sortSubLists[x_List] := Module[ {lev = Length[Dimensions[x]] - 1}, If[lev == 0, Sort[x], Map[Sort, x, lev]]]; list={5,2,8,3}; listNew=Table[list,{5}]; listNew1=Table[list, {3},{5}]; sortSubLists[list] {2,3,5,8} sortSubLists[listNew] {{2, 3, 5, 8}, {2, 3, 5, 8}, {2, 3, 5, 8}, {2, 3, 5, 8}, {2, 3, 5, 8}} sortSubLists[listNew1] {{{2, 3, 5, 8}, {2, 3, 5, 8}, {2, 3, 5, 8}, {2, 3, 5, 8}, {2, 3, 5, 8}}, {{2, 3, 5, 8}, {2, 3, 5, 8}, {2, 3, 5, 8}, {2, 3, 5, 8}, {2, 3, 5, 8}}, {{2, 3, 5, 8}, {2, 3, 5, 8}, {2, 3, 5, 8}, {2, 3, 5, 8}, {2, 3, 5, 8}}} Bob Hanlon ---- Arkadiusz Majka <Arkadiusz.Majka at telekomunikacja.pl> wrote: > Hi, > > Imagine that I want to sort (or do anything else) a list > > list={5,2,8,3} > > So I use Sort[list] > > Next I add next dimension and obtain a list listNew=Table[list,{5}] > > In order to sort all sublists of it it I use Map[Sort, listNew] > > Now I add another more dimension listNew1=Table[list, {3},{5}] > > I can again sort all sublists of it using combination of Table and Map. > > The question is the following: > > How can I deal with expresions of unknown a priori dimension? For > example what is the most elegant (clear and fast) method of sorting all > sublists of multidimensional expresion? I would like to avoid Table and > unclear expresions with many "Maps" (one embeded in another). > > Thanks for your help, > > Arek >