function sortPoints(p1, p2) {
        return g.line(p1, p2).squaredLength();
    }
Sorting function for list of points by their distance.
@param {g.point} p1 first point
@param {g.point} p2 second point
@return {number} squared distance between points