title: Sorting a MatchCollection in C#
body: <p>I am trying to rewrite TCL code in C#. The code of concern is the following:</p>
  
  <pre><code>set list [regexp -all -inline -line {.+\d+.+\d+} $string]
  </code></pre>
  
  <p>In this case the regexp procedure returns a list of all matches in the string after which I am sorting this list of strings with another expression based on a numeric value in the end of the string:</p>
  
  <pre><code>set sortedList [lsort -decreasing -integer -index end  $list]
  </code></pre>
  
  <p>The question is, how to achieve the same in C#? I tried the following: </p>
  
  <pre><code>MatchCollection mc = Regex.Matches(inputString, regexPattern, RegexOptions.Multiline);
  </code></pre>
  
  <p>As I found however, I cannot sort a matchcollection directly in C# so I copied every match to an array:      </p>
  
  <pre><code>string[] arrayOfMatches = new string[mc.Count];
  
  for (int i = 0; i &lt; mc.Count; i++)
  {
  arrayOfMatches[i] = mc[i].Groups[1].Value;
  }
  </code></pre>
  
  <p>However, when I try to sort the arrayOfMatches array, I do not see the Sort method available. What am I missing and am I moving in the right direction? Thanks!</p>