function sortBySize (dir = 1) {
  return (a, b) => (a - b) * dir
}
Numerical sort comparator.

@param {Number} dir - sorting direction, 1 for ascending or -1 for descending
@returns {(a:number, b:number) => number}