public static IEnumerable<string> 出現頻度の高い順に並べる(IEnumerable<string> texts)
{
var sortedList = new SortedList<string, int>();
foreach (var text in texts)
{
if (sortedList.ContainsKey(text))
{
sortedList[text]++;
}
else
{
sortedList.Add(text, 1);
}
}
return texts.OrderByDescending(x => sortedList[x]);
}
ICAgIAlwdWJsaWMgc3RhdGljIElFbnVtZXJhYmxlPHN0cmluZz4g5Ye654++6aC75bqm44Gu6auY44GE6aCG44Gr5Lim44G544KLKElFbnVtZXJhYmxlPHN0cmluZz4gdGV4dHMpCgkJewoJCQl2YXIgc29ydGVkTGlzdCA9IG5ldyBTb3J0ZWRMaXN0PHN0cmluZywgaW50PigpOwoJCQlmb3JlYWNoICh2YXIgdGV4dCBpbiB0ZXh0cykKCQkJewoJCQkJaWYgKHNvcnRlZExpc3QuQ29udGFpbnNLZXkodGV4dCkpCgkJCQl7CgkJCQkJc29ydGVkTGlzdFt0ZXh0XSsrOwoJCQkJfQoJCQkJZWxzZQoJCQkJewoJCQkJCXNvcnRlZExpc3QuQWRkKHRleHQsIDEpOwoJCQkJfQoJCQl9CgkJCXJldHVybiB0ZXh0cy5PcmRlckJ5RGVzY2VuZGluZyh4ID0+IHNvcnRlZExpc3RbeF0pOwoJCX0=