RE: when dimension increases
- To: mathgroup at smc.vnet.net
- Subject: [mg67600] RE: [mg67531] when dimension increases
- From: "David Park" <djmp at earthlink.net>
- Date: Sat, 1 Jul 2006 05:13:15 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Arek,
Here is a sample list...
list = Array[Random[] &, {2, 2, 3}]
{{{0.285035, 0.597228, 0.23606}, {0.559384, 0.693212, 0.455158}},
{{0.127923,
0.154882, 0.104625}, {0.0883025, 0.810242, 0.599067}}}
We just use a single Map but specify the specific level to sort, which is
the second from the bottom. This, of course, requires a uniform level
structure in the sublists.
Map[Sort, list, {-2}]
{{{0.23606, 0.285035, 0.597228}, {0.455158, 0.559384, 0.693212}},
{{0.104625,
0.127923, 0.154882}, {0.0883025, 0.599067, 0.810242}}}
Another approach would be...
Map[Sort, list, {Length[Dimensions[list]] - 1}]
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
From: Arkadiusz Majka [mailto:Arkadiusz.Majka at telekomunikacja.pl]
To: mathgroup at smc.vnet.net
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