title: Implementing custom IComparer with string
body: <p>I have a collection of strings in c#, for example;</p>
  
  <pre><code>var example = new string[]{"c", "b", "a", "d"};
  </code></pre>
  
  <p>I then with to sort this, but my IComparer method is not working, and looping infinitely by the seems of things.</p>
  
  <p>Basically I need <code>"b"</code> to come first, followed by <code>"c"</code>, then I dont care about the order of any of the others.</p>
  
  <p>Is this possible using I<code>Comparer&lt;string&gt;</code> and the <code>Compare(string x, string y)</code> method?</p>
  
  <p>Edit: Code</p>
  
  <pre><code>    public int Compare(string x, string y)
      {
          var sOrder = new string[] { "b", "c" };
          int index_x = -1;
          int index_y = -1;
  
          for (int i = 0; i &lt; sOrder.Length;i++)
          {
              if (sOrder[i] == x)
                  index_x = i;
              else if (sOrder[i] == y)
                  index_y = i;
          }
  
          if (index_x &gt;= 0 &amp;&amp; index_y &gt;= 0)
          {
              if (index_x &lt; index_y)
              {
                  return -1;
              }
              else
                  return 1;
          }
          return 0;
      }
  </code></pre>