JS- result.sort()

Just saying instead of using result.sort(), it should use result.sort((a, b) => a - b) as the default JS sort does not handle numbers well. If the test cases had diffs > single digit, then the current form wouldn’t have worked;

In any case you should always give comparator in javascript sort function.
From MDN

The default sort order is ascending, built upon converting the elements into strings, then comparing their sequences of UTF-16 code units values.

So always comparator, arrow functions are cool.