I wonder if you can move this function to the parent scope (and make it without if's e.g. `return (a.y - b.y) || (a.x - b.x);`)