title: Why the array is not sorted correctly?
body: <p>the problem is</p>
  <blockquote>
  <p>arange the columns of the array X (n, m) in ascending order.</p>
  </blockquote>
  <p>I wrote such code in c ++ myself, but in the end it does not sort all the columns correctly. Please help if anyone knows.</p>
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  int main() {
      int n, m;
      cout &lt;&lt; &quot;array size: n = &quot;;
      cin &gt;&gt; n;
      cout &lt;&lt; &quot;array size: m = &quot;;
      cin &gt;&gt; m;
      int array[n][m];
      int arrayS[n];
      for (int z = 0; z &lt; n; z++) {
          for (int a = 0; a &lt; m; a++) {
              cin &gt;&gt; array[z][a];
          }
      }
      for (int i = 0; i &lt; n; i++) {
          arrayS[i] = array[i][0];
      }
      for (int y = 0; y &lt; n; y++) {
          for (int i = 0; i &lt; m; i++) {
              cout &lt;&lt; array[y][i] &lt;&lt; &quot;    &quot;;
  
          }
          cout &lt;&lt; endl; //endline
      }
      cout &lt;&lt; &quot;************************************\n&quot;;
      cout &lt;&lt; &quot;massivin sutunlari\n&quot;;
      int enk = 0;
  
      for (int i = 0; i &lt; 9; i++)
          for (int j = 0; j &lt; 9; j++)
          {
              if (arrayS[j] &gt; arrayS[j + 1])
              {
                  enk = arrayS[j];
                  arrayS[j] = arrayS[j + 1];
                  arrayS[j + 1] = enk;
              }
          }
      for (int i = 0; i &lt; n; i++)
      {
          cout &lt;&lt; arrayS[i] &lt;&lt; &quot;  &quot;;
      }
  }
  </code></pre>