function compareMatricesAndArrays(x, y) {
    if (type.isSparseMatrix(x) && type.isSparseMatrix(y)) {
      return compareArrays(x.toJSON().values, y.toJSON().values);
    }

    if (type.isSparseMatrix(x)) {
      // note: convert to array is expensive
      return compareMatricesAndArrays(x.toArray(), y);
    }

    if (type.isSparseMatrix(y)) {
      // note: convert to array is expensive
      return compareMatricesAndArrays(x, y.toArray());
    } // convert DenseArray into Array


    if (type.isDenseMatrix(x)) {
      return compareMatricesAndArrays(x.toJSON().data, y);
    }

    if (type.isDenseMatrix(y)) {
      return compareMatricesAndArrays(x, y.toJSON().data);
    } // convert scalars to array


    if (!Array.isArray(x)) {
      return compareMatricesAndArrays([x], y);
    }

    if (!Array.isArray(y)) {
      return compareMatricesAndArrays(x, [y]);
    }

    return compareArrays(x, y);
  }
Compare mixed matrix/array types, by converting to same-shaped array.
This comparator is non-deterministic regarding input types.
@param {Array | SparseMatrix | DenseMatrix | *} x
@param {Array | SparseMatrix | DenseMatrix | *} y
@returns {number} Returns the comparison result: -1, 0, or 1