def _sort_baseline_facts(baseline_facts):
    """
    helper method to sort baseline facts by name before saving to the DB.
    """
    sorted_baseline_facts = sorted(baseline_facts, key=lambda fact: fact["name"].lower())
    for fact in sorted_baseline_facts:
        if "values" in fact:
            fact["values"] = sorted(fact["values"], key=lambda fact: fact["name"].lower())
    return sorted_baseline_facts