# How to arrange elements of a list

A file consists out of (x,y,z) data and I need the z-values arranged like this:

{{z[1],z[2],...z[idimx]},{z[idimx+1],z[idimx+2],...z[idimx*2]},{....}}

With

y=data[[All,2]]; z = data[[All, 3]];
iall=Length[z];
idimy=Length@Position[y,0];
idimx=iall/iy;


I get the dimensions of the array: {idimx,idimy}. But how can I now arrange it's elements? Thanks a lot.

-
Use Partition ? –  b.gatessucks Sep 12 '12 at 16:54
thanks, you were right, Partition does the job –  Harald Sep 12 '12 at 18:49

data = Thread[Join[{Tuples[{Range[3], Range[0, 9]}], Range[30]}]] /. {{a_, b_}, c_} -> {a, b, c}
y = data[[All, 2]];
idimy = Length@Position[y, 0];
idimx = Length@data/idimy;
zp = Partition[data[[All, 3]], idimx]
ListLinePlot@zp


Edit

Easier:

data = ....
zp = Split[data, #1[[2]] < #2[[2]] &][[All, All, 3]]
ListLinePlot@zp

-
ah, Partition is the key... Thanks a lot –  Harald Sep 12 '12 at 18:48
@Harald there are easier ways. See edit –  belisarius Sep 12 '12 at 19:18