{"size": 683, "ext": "js", "max_stars_repo_path": "9-Algorithms/SortByLength.js", "max_stars_repo_name": "StyvenSoft/Data-Structures-Javascript", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "9-Algorithms/SortByLength.js", "max_issues_repo_name": "StyvenSoft/Data-Structures-Javascript", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "9-Algorithms/SortByLength.js", "max_forks_repo_name": "StyvenSoft/Data-Structures-Javascript", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 20.696969697, "max_line_length": 95, "alphanum_fraction": 0.5124450952}
const sortByLength = (a, b) => {
    if (a.length < b.length) {
        return -1;
    } else if (a.length > b.length) {
        return 1;
    } else {
        return ascendingOrder(a, b);
    }
}

const ascendingOrder = (a, b) => {
    if (a < b) {
        return -1;
    } else if (a > b) {
        return 1;
    } else {
        return 0;
    }
}

// Use this array to test your code:
const testArray = ['car', 'train', 'plane', 'bike', 'skateboard', 'jet', 'purple', 'computer'];
testArray.sort(sortByLength);
console.log(testArray);

module.exports = sortByLength;

// [
//     'car', 'jet',
//     'bike', 'plane',
//     'train', 'purple',
//     'computer', 'skateboard'
// ]