code: function fixMultisigOrder (input, transaction, vin, value, network) {
    if (input.redeemScriptType !== scriptTypes.MULTISIG || !input.redeemScript) return
    if (input.pubKeys.length === input.signatures.length) return
  
    network = network || networks.bitcoin
    var unmatched = input.signatures.concat()
  
    input.signatures = input.pubKeys.map(function (pubKey) {
      var keyPair = ECPair.fromPublicKeyBuffer(pubKey)
      var match
  
      // check for a signature
      unmatched.some(function (signature, i) {
        // skip if undefined || OP_0
        if (!signature) return false
  
        // TODO: avoid O(n) hashForSignature
        var parsed = ECSignature.parseScriptSignature(signature)
        var hash
        switch (network.coin) {
          case coins.BSV:
          case coins.BCH:
            hash = transaction.hashForCashSignature(vin, input.signScript, value, parsed.hashType)
            break
          case coins.BTG:
            hash = transaction.hashForGoldSignature(vin, input.signScript, value, parsed.hashType)
            break
          case coins.ZEC:
            if (value === undefined) {
              return false
            }
            hash = transaction.hashForZcashSignature(vin, input.signScript, value, parsed.hashType)
            break
          default:
            if (input.witness) {
              hash = transaction.hashForWitnessV0(vin, input.signScript, value, parsed.hashType)
            } else {
              hash = transaction.hashForSignature(vin, input.signScript, parsed.hashType)
            }
            break
        }
  
        // skip if signature does not match pubKey
        if (!keyPair.verify(hash, parsed.signature)) return false
  
        // remove matched signature from unmatched
        unmatched[i] = undefined
        match = signature
  
        return true
      })
  
      return match
    })
  }
docs: could be done in expandInput, but requires the original Transaction for hashForSignature