Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Word Count Engine sorting not stable #1

Open
domfarolino opened this issue Oct 15, 2018 · 0 comments
Open

Word Count Engine sorting not stable #1

domfarolino opened this issue Oct 15, 2018 · 0 comments

Comments

@domfarolino
Copy link

I believe your implementation of Word Count Engine may have some errors. With an input string like "z y x o n m d c b a", your solution does not always maintain the relative order in which words with the same occurrence. While Collections.sort does guarantee a stable sort, iterating over the keys in a HashMap is not guaranteed to give you keys in insertion order, and in fact no guarantee is made on the order of key retrieval here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant