Re: Sorting the Elements of a Non Rectangular List
- To: mathgroup at smc.vnet.net
- Subject: [mg51194] Re: [mg51181] Sorting the Elements of a Non Rectangular List
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Fri, 8 Oct 2004 02:54:41 -0400 (EDT)
- References: <200410070926.FAA10805@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 7 Oct 2004, at 18:26, Richard Palmer wrote: > *This message was transferred with a trial version of CommuniGate(tm) > Pro* > Make two data structures h1 and h2. > > \!\(\(h1 = > Sort[Table[key\_\(Random[Integer, {1, 30}]\), {i, 1, 8}]] > /. > key\_i_ -> {key\_i, info\_\(i, 1\), info\_\(i, 2\)};\)\) > > \!\(\(h2 = > Sort[Table[{key\_\(Random[Integer, {1, 30}]\), > > Sort[Table[ > info\_\(Random[Integer, {3, 20}]\), {Random[ > > Integer, {0, 12}]}]]}, {9}]];\)\) > > Define a function tensorize which adds keys that aren't on one set onto > another. > > tensorize[x_, using_] := > Flatten[{x, > > Transpose[{Complement[First[Transpose[using]], First[Transpose[x]]]}]}, > > 1] > > How do I sort tensorize[h1,h2] into key order? > > Sort[tensorize[h1,h2]] does not work and > Sort[tensorize[h1,h2],First[#1]<=Sort[#2]&] does not work? > > Thanks in advance. > > Do you mean: Sort[tensorize[h1, h2], #1[[1, 2]] <= #2[[1, 2]] &] ? Andrzej Kozlowski Andrzej Kozlowski Chiba, Japan http://www.akikoz.net/~andrzej/ http://www.mimuw.edu.pl/~akoz/
- References:
- Sorting the Elements of a Non Rectangular List
- From: Richard Palmer <mapsinc@bellatlantic.net>
- Sorting the Elements of a Non Rectangular List