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.
Nice!
So it seems that the problem is in handling equal-priority.
As we can see from the line
if (... element.priority <= max) {
pay attention that it's<=
, not<
if there are items with equal priority, @ben-hig's solution always takes the rightmost one.
Since order for items with same priorities are not specified in kata description, technically @ben-nig is right.
@jfrei, it seems that you're expecting FIFO, but does not explicitly require that in solution.
Moreover, language specification does not guarantee that built-in sort is stable: es5.1, es6.0
Hey ben-hig: So, I went through the test cases for the solution, but it is using a very simple sort function:
items.sort(function(a,b) {return a.priority - b.priority;});
Without trying to 'point a finger' at your code, I think there is some inconsistency with how you are dealing with sorting the items. I tried to get your solution to work by modifiying the test case sort, but that doesn't help at all. I think you may need to modify your solution to handle the sorting properly.Thanks for bringing that up; Will have to get that fixed up!
My solution doesn't pass sometimes on the last randomized test case, and it seems to be due to inconsistency with how the case of two items having the same priority is handled. It seems to be a toss-up for which one is shipped first.
i think it's there for making sure your code is below a certain length
This comment is hidden because it contains spoiler information about the solution