Ad
  • Custom User Avatar

    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

  • Custom User Avatar

    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.

  • Custom User Avatar

    Thanks for bringing that up; Will have to get that fixed up!

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    i think it's there for making sure your code is below a certain length