MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: ordered positions (OrderedPosition?)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83420] Re: ordered positions (OrderedPosition?)
  • From: Thomas E Burton <tburton at brahea.com>
  • Date: Tue, 20 Nov 2007 03:47:18 -0500 (EST)

I decided to bypass Ordering:

orderedPosition[data_List, n_Integer]:=
   Module[{d=Depth[data], idxdata=MapIndexed[List,data,{-n}]},
     Rest/@Sort[Flatten[idxdata, d-1-n]] /; 0<n<d
]

data should be a tensor (or a full nested list or whatever one calls  
it). n is the level at which you want the ordering. I tested it with

data = Table[RandomInteger[10], {3}, {4}, {3}, {4}]

Tom

> I am wanting an elegant solution to find an ordering of elements of  
> a set of nested lists at a specific level (the base level in this  
> case but need not be). The output I am after is an ordered set of  
> positions that references each of those elements in the original  
> structure.


  • Prev by Date: Re: data structures in Mathematica
  • Next by Date: Variable-length list?
  • Previous by thread: Re: ordered positions (OrderedPosition?)
  • Next by thread: Re: ordered positions (OrderedPosition?)