Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
clean, but the intital split/filter repetition seems a bit high in performance cost and very reduceable.
20 lines? 🙂
Pretty clean, love it
Or you could just use a.localeCompare(b) instead of trying to find the index.Misread that.I'd say the best say is
[...'abcdefghijklmnopqrstuvwxyz']
The right hand side of the
||
is only evaluated if the left hand side is zero (a falsy value). So the sorting prioritizescount
(objects with higher count come first), and when bothcount
s are equal, the next condition is used (alphabetical sorting, bysrc
and then bychar
).can somebody explain me, what exactly happening or we doing in the sort after
||
or after the OR part?Nice usage of ternary operator and sort method. I learned a lot from this solution, thanks.
I don't understand why you think this is good solution. You have to cycle for every alpabeth character (no matter if it present in the strings) and then you have to loop through each string to check if that character belongs to it. I don't see this as good performance. There is a trend here that nested functions are always the solution and, while they have their beauty, sometimes shouldn't be consider as a choice to solve a problem.
I've really learnt a lot from your code.
Not only is that a really clever solution - it is also a really clear and straightforward solution ;)
This bit of code has helped me immensely on how to look at and disect some fo these problems.
Thanks!
Not too much difference between 15 objects and 26 objects inside an array.
Other top solutions have nested loops. This one doesn't actually have nested loops, it just chains several iterators. And nested loops aren't always a bad thing.
I wonder why do this solution have relatively so little upvotes. Maybe because of 26 separate objects or loops inside loops? Anyway it looks so neat and cool.