import hashlib


def hash_reactions(reactions, sort=True):
    """
    Creates a hash for a list of reactions

    :param reactions: the reactions to hash
    :type reactions: list of Reaction
    :param sort: if True will sort all molecules, defaults to True
    :type sort: bool, optional
    :return: the hash string
    :rtype: str
    """
    hash_list = []
    for reaction in reactions:
        hash_list.extend(reaction.hash_list())
    if sort:
        hash_list.sort()
    hash_list = ".".join(hash_list)
    return hashlib.sha224(hash_list.encode("utf8")).hexdigest()