Okay, so this is an odd bug in node, but when I get a Table of Contents with exactly 11 headers, they come back in the wrong order, with the 6th one first.
According to the docs on MDN, the compareFunction for Array.sort() should return an integer of -1, 0, or 1. Although returning false works in most other browsers and javascript engines I've tried, it might be better to return the expected values.
Okay, so this is an odd bug in node, but when I get a Table of Contents with exactly 11 headers, they come back in the wrong order, with the 6th one first.
Here's a simple reproducible example
According to the docs on MDN, the
compareFunction
forArray.sort()
should return aninteger
of-1
,0
, or1
. Although returning false works in most other browsers and javascript engines I've tried, it might be better to return the expected values.In the docs on MDN, they suggest using a
-
sign for comparing numbers:So a super minor edit, but one that hits this odd edge case.