foreach (string word in words)
{
if (word != "")
{
if (hash.ContainsKey(word))
{
hash[word]++;
}
else
{
hash[word] = 1;
}
}
}
}
List<KeyValuePair<string, int>> list
= new List<KeyValuePair<string, int>>(hash);
list.Sort(delegate(KeyValuePair<string, int> kvp1, KeyValuePair<string, int> kvp2) {
return kvp2.Value - kvp1.Value;});
foreach (KeyValuePair<string, int> kvp in list)
{
Console.WriteLine("{0} {1}", kvp.Key, kvp.Value);
}
}
}
}