From e63545c462a742d77b8e637d61ff6cd8d7d10d46 Mon Sep 17 00:00:00 2001 From: zhaowei <zhaowei@igengmei.com> Date: Fri, 7 Aug 2020 11:45:57 +0800 Subject: [PATCH] sort with order --- eda/smart_rank/tag3_portrait_to_es.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eda/smart_rank/tag3_portrait_to_es.py b/eda/smart_rank/tag3_portrait_to_es.py index ee2f8e6d..fd785c8f 100644 --- a/eda/smart_rank/tag3_portrait_to_es.py +++ b/eda/smart_rank/tag3_portrait_to_es.py @@ -42,7 +42,8 @@ def user_portrait_scan_info(): def _dict_to_name_score(d): res = [] - for (k, v) in d.items(): + new_d = dict(sorted(d.items(), key=lambda x: x[1], reverse=True)) + for (k, v) in new_d.items(): res.append({"name": k, "score": float(v)}) return res -- 2.18.0