si-funciona
    Preparing search index...

    Function compareArrays

    • Compare two Arrays and return the Object where the value for each property is as follows: -1 to indicate val1 is less than val2 0 to indicate both values are the equal 1 to indicate val1 is greater than val2 The returned Object uses the element values as the property names This functions works by first creating a concatenated array of all unique values. Then for each unique values, convert to a string and use it as a new property name. Array filter each array checking if it has the unique value. Use the lengths of these filtered arrays to compare. So if the first array has the value and the second one doesn't the first length will be one or more and the second will be zero, if the both have the value then both will be one or more.

      Parameters

      • ...arrays: any[][]

        The arrays to compare

      Returns compareArrayResultMap

      // example of input and resulting output
      compareArrays(
      ['match1', 'firstMismatch1', 'match2', 'firstMismatch2', 'badMatch1'],
      ['match1', 'match2', 'secondMismatch1', 'badMatch1', 'badMatch1']
      )
      // unique array
      ['match1', 'firstMismatch1', 'match2', 'firstMismatch2', 'badMatch1', 'secondMismatch1']
      // result object
      [
      {
      value: 'match1',
      keys: [[0], [0]],
      result: [0, 0]
      },
      {
      value: 'firstMismatch1',
      keys: [[1], []],
      result: [1, -1]
      },
      {
      value: 'match2',
      keys: [[2], [1]],
      result: [0, 0]
      },
      {
      value: 'firstMismatch2',
      keys: [[3], []],
      result: [1, -1]
      },
      {
      value: 'badMatch1',
      keys: [[4], [3, 4]],
      result: [0, 0]
      },
      {
      value: 'secondMismatch1',
      keys: [[], [2]],
      result: [-1, 1]
      }
      ]