Advertisement
huutho_96

sort C# 2d array

Mar 13th, 2017
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace CS
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int m = 5;
  14.             int n = 6;
  15.             int[,] a = new int[,]{
  16.                 {1, 4, 7, 2, 4, 3},
  17.                 {3, 2, 4, 6, 7, 1},
  18.                 {9, 2, 6, 1, 8, 3},
  19.                 {6, 2, 7, 9, 2, 5},
  20.                 {6, 8, 1, 6, 2, 5}
  21.             };
  22.             for (int i = 0; i < m; i++)
  23.             {
  24.                 for (int j = 0; j < n; j++)
  25.                 {
  26.                     for (int k = 0; k < m; k++)
  27.                     {
  28.                         for (int l = 0; l < n; l++)
  29.                         {
  30.                             if (a[i, j] < a[k, l])
  31.                             {
  32.                                 int temp = a[i, j];
  33.                                 a[i, j] = a[k, l];
  34.                                 a[k, l] = temp;
  35.                             }
  36.                         }
  37.                     }
  38.                 }
  39.             }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement