title: Shuffling multidimensional array in js
body: <p>This function shuffles only matrix[y], but I want it to shuffle matrix[y][x] But it doesn't want to shuffle correctly.</p>
  
  <p>The code what I used:</p>
  
  <pre><code>function Shuffle(arguments) {
      for (var k = 0; k &lt; arguments.length; k++) {
          var i = arguments[k].length;
          if (i == 0)
              return false;
          else {
              while (--i) {
                  var j = Math.floor(Math.random() * (i + 1));
                  var tempi = arguments[k][i];
                  var tempj = arguments[k][j];
                  arguments[k][i] = tempj;
                  arguments[k][j] = tempi;
              }
              return arguments;
          }
      }
      return arguments
  }
  
  var matrix = [
  
  ];
  
  var ab = 36;
  
  for (var y = 0; y &lt; ab; y++) {
      matrix.push([])
      for (var x = 0; x &lt; ab; x++) {
          matrix[y][x] = Math.floor(Math.random() * 1)
      }
      for (var x = 0; x &lt; ab / 2; x++) {
          matrix[y][x] = 1
      }
  }
  
  
  arr = Shuffle(matrix);
  
  console.log(arr)
  var side = 16;
  
  function setup() {
  
      createCanvas(arr[0].length * side, arr.length * side);
      background('#acacac');
      frameRate()
  
  }
  
  function draw() {
      for (var y = 0; y &lt; arr.length; y++) {
          for (var x = 0; x &lt; arr[y].length; x++) {
  
              if (matrix[y][x] == 0) {
                  fill(0, 255, 0)
                  rect(y * side, x * side, side, side)
              } else if (matrix[y][x] == 1) {
                  fill("red")
                  rect(y * side, x * side, side, side)
              } else if (matrix[y][x] == 2) {
                  fill(255, 255, 0)
                  rect(y * side, x * side, side, side)
              } else if (matrix[y][x] == 3) {
                  fill(255, 0, 0)
                  rect(y * side, x * side, side, side)
              }
          }
      }
  }
  </code></pre>
  
  <p>So this function shuffles only matrix[y], but I want it to shuffle matrix[y][x].
  Any ideas? Here is the screenshot:</p>
  
  <p><img src="https://i.stack.imgur.com/WJ9qZ.png" alt="enter image description here">.</p>