const formatter = class Formatter {

    format(result) {
        result.coAuthors.sort(this._alphabeticalSort);
        let str = `"${result.name}" has ${result.coAuthors.length} coauthors:`;
        for (const index in result.coAuthors) {
            str += `\n- ${result.coAuthors[index]}`;
        }
        return str;
    }

    _alphabeticalSort(a, b) {
        return (a > b) ? 1 : -1;
    }

};

module.exports = formatter;
