开发者

Recreate array so that array[x][y] become newarray[y][x]

Is there a standard method to create a new array from a two dimensional array so that array[x][y] would be accessed as [y][x] on the new array?

For example, from:

[ [00,01,02,03,04,开发者_JS百科05],
  [10,11,12,13,14,15],
  [20,21,22,23,24,25] ]

Would become:

[ [00,10,20],
  [01,11,21],
  [02,12,22],
  [03,13,23],
  [04,14,24],
  [05,15,25] ]


I believe you are looking for Array#transpose

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜