TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Tj
NA
10
0
SortedList for Letter Frequency?
Apr 8 2010 5:50 PM
Just wondering what data type you guys would recommend for counting up the occurrences of letters A->Z in words, and THEN sorting from Most Frequent letter to Least Frequent?
SortedList<string, int> sl = new SortedList<string, int>()
for (char i = 'A'; i <= 'Z'; i++)
{
sl.Add(i.ToString(), 0);
}
lends itself pretty well to getting a distribution (so that the integer is incremented with each occurrence of '
A
', '
B
', '
C
' etc.)
In the 'olden days' (using C++) I'd probably have sorted a fixed array (26 of a char/int struct) - can you suggest a better way in C#?
Would received wisdom dictate using ICompareTo(), Sort or something?
Reply
Answers (
3
)
Help with Enum...
C#: Treeview from Database ( 3 tables) window application