public static function nameComparator(): Closure
    {
        return static function (GedcomRecord $x, GedcomRecord $y): int {
            if ($x->canShowName()) {
                if ($y->canShowName()) {
                    return I18N::strcasecmp($x->sortName(), $y->sortName());
                }

                return -1; // only $y is private
            }

            if ($y->canShowName()) {
                return 1; // only $x is private
            }

            return 0; // both $x and $y private
        };
    }