Re: sort and positon matrix element help

*To*: mathgroup at smc.vnet.net*Subject*: [mg73091] Re: sort and positon matrix element help*From*: dh <dh at metrohm.ch>*Date*: Thu, 1 Feb 2007 04:36:07 -0500 (EST)*References*: <epp6nn$dcl$1@smc.vnet.net>

Hi, If I understand correctly, you want to sort the elements of a matrix and retaining the row/col info.m Assume the matrix is: m: We first create an index matrix: ind = Table[{i, j}, {i, Length[m]}, {j, Length[m[[1]]]}] then we "join" both matrices and flatten it to a list with elements {number,{row,col}}: t = MapThread[{#1, #2} &, {m, ind}, 2] t = Flatten[t, 1] Now we sort according to the first element of {number,{row,col}} : Sort[t, #1[[1]] < #2[[1]] &] Daniel comp.soft-sys.math.mathematica wrote: > Hi, guys, > > I am attacking one proble and may need your help. > I have a large matrix(m*n). I wanna to sort out the matrix > from large to small according to its element's value AND save the > corresponding row and column number as its position. Latter on, plot > out the first 20 largest value accroding to their positions. > Is there any good way to do this, especially take out the > positons of element and assocate it with the value? >