code: function _sortWishesByMatchingPriority(
    wishes,
    currentMatchingWishIds,
    givenMagicWord,
  ) {
    const matchPriorityArrays = []
    let returnedIds = []
  
    _each(
      wishes,
      wish => {
        if (_wishInContext(wish)) {
          const matchPriority = _bestMagicWordsMatch(
            wish.magicWords,
            givenMagicWord,
          )
          _maybeAddWishToMatchPriorityArray(
            wish,
            matchPriority,
            matchPriorityArrays,
            currentMatchingWishIds,
          )
        }
      },
      true,
    )
  
    _each(
      matchPriorityArrays,
      matchTypeArray => {
        if (matchTypeArray) {
          _each(matchTypeArray, magicWordIndexArray => {
            if (magicWordIndexArray) {
              returnedIds = returnedIds.concat(magicWordIndexArray)
            }
          })
        }
      },
      true,
    )
    return returnedIds
  }
docs: A matchPriority for a wish
  @typedef {object} MatchPriority
  @property {number} matchType - based on _matchRankMap
  @property {number} magicWordIndex - the index of the magic word
  in the wish's array of magic words.
   
  Takes the given wishes and sorts them by how well they match the givenMagicWord.
  The wish must be in context, and they follow the order defined in the
  {@link "#_matchRankMap"}
  @param {*} wishes
  @param {Array.<string>} currentMatchingWishIds
  @param givenMagicWord
  @returns {Array.<string>}
  @private