import math


def softmax(predictions):
    """Returns the softmax values from a distribution given as a dictionary
    like:
        {"category": {"probability": probability, "order": order}}

    """
    total = 0.0
    normalized = {}
    for category, cat_info in predictions.items():
        normalized[category] = { \
            "probability": math.exp(cat_info["probability"]),
            "order": cat_info["order"]}
        total += normalized[category]["probability"]
    return float('nan') if total == 0 else \
        {category: {"probability": cat_info["probability"] / total,
                    "order": cat_info["order"]}
         for category, cat_info in normalized.items()}