def get_sign_alg(keyjar, iss=''):
    """
    Based on the keys in a keyjar and a order of priority
    between key types pick the 'best' signing algorithm.

    :param keyjar: A :py:class`oidcmsg.key_jar.KeyJar` instance
    :param iss: An identifier for an issuer
    :return: The name of a signing algorithm
    """
    priority_order = ['EC', 'RSA', 'OCT']
    po_inv = {'EC': 'ES256', 'RSA': 'RS256', 'OCT': 'HS256'}

    best = len(priority_order) - 1
    for key in keyjar.get_signing_key(owner=iss):
        if priority_order.index(key.kty) < best:
            best = priority_order.index(key.kty)

    return po_inv[priority_order[best]]