コード例 #1
0
 int[,] IMatrixSort.SortMatrix(int[,] inputMatrix, int row, int column, int[] indexes, bool descending)
 {
     int[] rowSum   = MatrixHelper.RowsSum(inputMatrix, row, column);
     int[] tempRows = new int[row];
     rowSum.CopyTo(tempRows, 0);
     Array.Sort(rowSum, indexes);
     if (descending)
     {
         Array.Reverse(indexes);
     }
     int[,] sortedMatrix = new int[row, column];
     for (int i = 0; i < row; i++)
     {
         for (int j = 0; j < column; j++)
         {
             sortedMatrix[i, j] = inputMatrix[indexes[i], j];
         }
     }
     return(sortedMatrix);
 }
コード例 #2
0
 int[,] IMatrixSort.SortMatrix(int[,] inputMatrix, int rows, int columns, int[] indexes, bool descending)
 {
     int[] minimumValues = MatrixHelper.MinimumRowValue(inputMatrix, rows, columns);
     int[] tempRows      = new int[rows];
     minimumValues.CopyTo(tempRows, 0);
     Array.Sort(minimumValues, indexes);
     if (descending)
     {
         Array.Reverse(indexes);
     }
     int[,] sortedMatrix = new int[rows, columns];
     for (int i = 0; i < rows; i++)
     {
         for (int j = 0; j < columns; j++)
         {
             sortedMatrix[i, j] = inputMatrix[indexes[i], j];
         }
     }
     return(sortedMatrix);
 }