title: Sort for Matrix
body: <p>I have a problem with matrix sort.</p>
  <p>I need to create a matrix (MxM) from <strong>input</strong>. And create nested lists using <strong>randrange</strong>.</p>
  <pre><code>matrix_size = int(input(&quot;Enter size of the matrix: &quot;))
  matrix = [[randrange(1, 51) for column in range(matrix_size)] for row in range(matrix_size)]
  </code></pre>
  <p>Next step i should <strong>find sum of each column of matrix.</strong> So i do this thing:</p>
  <pre><code>for i in range(matrix_size):
  sum_column = 0
  for j in range(matrix_size):
      sum_column += matrix[j][i]
      print(f'{matrix[i][j]:&gt;5}', end='')
  print(f'{sum_column:&gt;5}')    
  </code></pre>
  <p>So problem is... that i should add sum row in the end of a matrix. But what happens to me:</p>
  <pre><code>Enter the size of the matrix: 5
  
     15    23    14    22    20    73
      7    26    26    27    27   160
     17    36     9    13    42   104
      1    32    41     2    29   113
     33    43    14    49    12   130
  </code></pre>
  <p>Yeah. It counting right but how i can add it to the end of matrix. And sort ascending to the sums of columns. Hope some of you will understand what i need. Thanks</p>