title: How can i sort two dimentional array with linq and with Compareto method?
body: <p>How can i sort 2D array with linq and without linq with Copareto . i can do that with list generic . But i dislike it. can you give any idea about it?</p>
  
  <p><pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Data;</p>
  
  <p>namespace TestFillArray
  {
      class Program
      {
          static void Main(string[] args)
          {</p>
  
  <code>        DataTable table = GetTable();
          int[,] mySortedLists = new int[table.Rows.Count, table.Columns.Count];
          for (int i = 0; i &amp;#60; table.Rows.Count; i++)
          {
              for (int j = 0; j &amp;#60; table.Columns.Count; j++)
              {
                  mySortedLists[i, j] += table.Rows[i][j].ToString().Length;
              }
          }
  
          List&amp;#60;int&amp;#62; list = new List&amp;#60;int&amp;#62;();
  
          for (int i = 0; i &amp;#60; table.Rows.Count; i++)
          {
              for (int j = 0; j &amp;#60; table.Columns.Count; j++)
              {
                  Console.WriteLine(mySortedLists[i, j].ToString());
                  list.Add(int.Parse(mySortedLists[i, j].ToString()));
              }
          }
  
          list.Sort();
          list.Reverse();
  
          foreach (int item in list)
          {
              Console.WriteLine(item.ToString());
          }
          Console.ReadKey();
  
  
      }
  
      static DataTable GetTable()
      {
          //
          // Here we create a DataTable with four columns.
          //
          DataTable table = new DataTable();
          table.Columns.Add("Dosage", typeof(int));
          table.Columns.Add("Drug", typeof(string));
          table.Columns.Add("Patient", typeof(string));
          table.Columns.Add("Date", typeof(DateTime));
  
          //
          // Here we add five DataRows.
          //
          table.Rows.Add(25, "Indocin", "David", DateTime.Now);
          table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now);
          table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now);
          table.Rows.Add(21, "Combivent", "Janet", DateTime.Now);
          table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now);
  
          return table;
      }
  }
  </code></pre>
  
  <p>}
  </code></p>