diff --git a/agent.py b/agent.py index b88aff2..036e5c4 100644 --- a/agent.py +++ b/agent.py @@ -403,17 +403,9 @@ def _score_quotes(comparison_id: str, quotes: list[QuoteInput], weights: QuoteWe } ) - scored.sort( - key=lambda item: ( - -item["scores"]["weighted_total"], - item["subtotal"], - item["delivery_days"], - -item["warranty_months"], - item["vendor"].lower(), - ) - ) + scored.sort(key=_score_sort_key) winner = scored[0] - baseline = min(scored, key=lambda item: item["subtotal"]) + baseline = min(scored, key=_subtotal_key) rationale_bits = [ f"{winner['vendor']} has the highest weighted score ({winner['scores']['weighted_total']:.2f}).", f"Its normalized total is {winner['subtotal']:.2f} for {winner['quantity']} units.",