def values_sorted_by_key_list(dictionary, key_list, ignore_non_existing=True):
    """
    This function returns the values of a dictionary accorded to a list of keys. The key list should contain
    keys that the dictionary has. For example:
    >> d = {'a': 1, 'b': 2, 'c': 3}
    >> values_sorted_by_key_list(d, ['b', 'a'])
    >> [2, 1]
    :param dictionary: data dictionary
    :param key_list: keys whose values must be returned
    :param ignore_non_existing: whether to raise an exception or not when a key does not exist in dictionary
    :return: list
    """
    output = list()
    for key in key_list:
        try:
            output.append(dictionary[key])
        except KeyError as e:
            if ignore_non_existing:
                continue
            else:
                raise e
    return output