4
Good Afternoon! I have assembled an array that receives 9 records from a single variable and the values are displayed on the user screen. However, when trying to put this matrix in ascending order, I tried to use the method of exchanging values, only when applying it to this algorithm, the last three values typed via keyboard were repeated three times:
var linha = Array(3,3);
var x, y, troca;
for (x = 0; x < 3; x++) {
  for (y = 0; y < 3; y++) {
      linha[x,y] = parseInt(prompt("Digite o "+[y+1]+"º número da "+[x+1]+"º coluna"));
  }
}
for (x = 0; x < 3; x++) {
  for (y = 0; y < 3; y++) {
    if (linha[x] < linha[y]){
      troca = linha[x];
      linha[x] = linha[y];
      linha[y] = troca;
    }
  }
}
for (x = 0; x < 3; x++) {
  for (y = 0; y < 3; y++) {
    document.write(linha[x,y]+"  ");
  }
  document.write("<br>");
}Question: Which method would be simpler and logical to sort the 9 numbers typed by the user in ascending order in this presented problem?

Thank you @Brunorigolon for your help and collaboration. This was a challenge I had to make and I was not managing to finish it and your contribution helped me understand it more. :-)
– pe.Math