Diff two sorted array for best performance
npm install diff-sorted-array

Diff two sorted array for best performance.
``sh`
$ npm i diff-sorted-array
`js`
const {diff, justDiff, asc, desc} = require('diff-sorted-array')
- a ArrayArray
- b
`js
const a = [2, 3, 1]
const b = [3, 4, 2]
const result = diff(a, b, sorter)
result.unchanged
// [2, 3]
result.added
// [4]
result.deleted
// [1]
`
- sorter Function(a: any, b: any): number the compareFunction of Array.prototype.sort(compareFunction)
Sometimes we want to do the sorting ourself, so that we can manage the process to increase performance.
justDiff only accepts two arrays that both have already been sorted to speed up the matching.
`js
const sorter = (a, b) => a > b
? 1
: - 1
const a = [2, 3, 1]
const b = [3, 4, 2]
a.sort(sorter)
b.sort(sorter)
justDiff(a, b, sorter)
// The same result as above
``
Built-in sorter to sort arrays in ascending or descending order.