text: import {
    NotImplementedError
  } from '../extensions/index.js';
  
  /**
   * Given an array with heights, sort them except if the value is -1.
   *
   * @param {Array} arr
   * @return {Array}
   *
   * @example
   * arr = [-1, 150, 190, 170, -1, -1, 160, 180]
   *
   * The result should be [-1, 150, 160, 170, -1, -1, 180, 190]
   */
  export default function sortByHeight(arr) {
    let numb = [];
    let res = [];
    let count = 0;
    for (let i = 0; i < arr.length; i++) {
      if (arr[i] !== -1) {
        numb.push(arr[i]);
      }
    }
    let sortNumb = [];
    sortNumb = numb.sort((a, b) => a - b);
  
    for (let i = 0; i < arr.length; i++) {
      if (arr[i] !== -1) {
        res.push(sortNumb[i - count]);
      } else {
        res.push(-1);
        count++;
      }
    }
    return res;
  }