I need some help. Basically, I have a paragraph of text in a text file, and I need to read the textfile (stored as a string) into a List of characters and stores the amount of time they appear inside the string. So it will produce a list between (A-Z) and order it depending on how many times the characters appear. Is there a way to do this without using LINQ.
Thank you 🙂
An efficient and easy way is to create a
ConcurrentDictionarywith the char as key and the number it appears as value. It has the nice AddOrUpdate(upsert) method:If you want to order it by the number without Linq(Lambda != Linq) you can use this code:
Edit: If you want to order descending change above a little bit:
result: