title: Using .ToDictionary()
body: <p>I have a method returning a List, let's call it <code>GetSomeStrings()</code>.</p>
  
  <p>I have an extension method on string class, returning number of characters in the string, eg. <code>myString.Number('A')</code>.</p>
  
  <p>I would like to, in a single line, grab a dictionary. An entry of the dictionary contains the string, and the number of a chosen character in the string.</p>
  
  <p>Actually I do the following:</p>
  
  <pre><code>var myDic = GetSomeStrings().ToDictionary(x=&gt;x.Number('A'));
  </code></pre>
  
  <p>which gives me a dictionary <code>&lt;int,string&gt;</code>; I would like the key as the string.</p>
  
  <p>After, I'd like to order the dictionary on the int value. It is possible to include this in the previous statement ?</p>
  
  <p>I'd really like to avoid a collection enumeration to sort or create the dictionary from the list, which is what i do actually without troubles. Thank you for your optimization help !</p>