const bubble = (array) => {
  for (let i = 0; i < array.length; i++) {
    for (let j = 0; j < array.length; j++) {
      let first = array[j]
      let second = array[j + 1]

      // first > second, then we swap it
      if (first >= second) {
        array[j] = second
        array[j + 1] = first
      }
    }
  }

  return array
}

module.exports = bubble
