text: const { NotImplementedError } = require('../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]
   */
  function sortByHeight(arr) {
    //throw new NotImplementedError('Not implemented');
    let ind = []
    let sortArr = arr.slice().filter((item, index) => {
      if (item === - 1 ) {
        ind.push(index)
      } else {
        return item > 0
      }
    }).sort((a,b) => a - b)
  
    for (let i = 0; i < ind.length; i++) {
      sortArr.splice(ind[i], 0, -1)
    }
  /*console.log(sortArr)
    console.log(ind) */
    return sortArr
    // remove line with error and write your code here
  }
  
  module.exports = {
    sortByHeight
  };
  