Originally Posted by
Daved
Do you need to sort the counts? I don't think you do. Do you even need to store the counts? I think that when you find that skrivning[u] != lastword you can just output lastword and the count before starting the new count.
Also note that you have a few bugs in the code as it is. Make sure to initialize u if you keep it, you probably want continue instead of break, and the first value for lastword should be skrivning[0] if you're going to initialize it with something (you can also get it to work with it starting out empty if you want).