{"size": 353, "ext": "js", "max_stars_repo_path": "Smooth sailing - sortByHeight.js", "max_stars_repo_name": "saqy/codesignal-js-solutions", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Smooth sailing - sortByHeight.js", "max_issues_repo_name": "saqy/codesignal-js-solutions", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Smooth sailing - sortByHeight.js", "max_forks_repo_name": "saqy/codesignal-js-solutions", "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": 18.5789473684, "max_line_length": 41, "alphanum_fraction": 0.5184135977}
function sortByHeight(a) {
  let treeIndexes = [];
  let result = a
    .filter((currValue, index) => {
      if (currValue === -1) {
        treeIndexes.push(index);
      } else {
        return currValue;
      }
    })
    .sort((a, b) => a - b);

  treeIndexes.forEach((value, index) => {
    result.splice(value, 0, -1);
  });

  return result;
}
