Closed davazp closed 6 years ago
Perhaps replace sort with a stable sort like the one implemented at
?
Is your issue with more than 10 child routes in Chrome (V8)?
Yes, I have more than 10 routes and V8 (but on NodeJS).
Sort is unstable on V8 for arrays with more than 10 items. Can you make a PR to not return 0 and instead return the index difference?
Hi,
According to this comment in the
.add()
method:https://github.com/troch/route-node/blob/master/modules/RouteNode.js#L111-L142
the order of the routes should be preserved if they are equivalent under all the conditions (same length of the last segment) and so on. However, it uses the
sort
method of an array, which does not ensure the sort is stable:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
We found a weird issue where the order of the routes swapped two routes each time a new route was added to the router.
Please, let's add extra conditions to avoid returning 0 from the sort callback!
Thanks!