From c9a665b161adc558c15ce3d3caec74be592a1668 Mon Sep 17 00:00:00 2001 From: viyrs <2991883280@qq.com> Date: Sat, 28 Feb 2026 21:42:36 +0800 Subject: [PATCH] =?UTF-8?q?refactor(check=5Fblocks):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=96=B9=E5=9D=97=E6=8A=A5=E5=91=8A=E6=8E=92=E5=BA=8F=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改排序算法,从按完成状态标志排序改为按实际数量降序排序 - 使用负数技巧实现合成配方和破坏掉落数量的降序排列 - 更新注释说明新的排序规则为按完成度降序 --- check_blocks.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/check_blocks.py b/check_blocks.py index 1a04298..039ecad 100644 --- a/check_blocks.py +++ b/check_blocks.py @@ -129,13 +129,12 @@ def write_markdown_report( lines.append("| 方块名 | 合成配方 | 破坏掉落 |") lines.append("| ------ | -------- | -------- |") - # 排序:优先显示 recipe 和 loot 都完成的方块,然后再显示有缺失的 + # 排序:按完成度降序(先按合成配方数量降序,再按破坏掉落数量降序) def sort_key(block_name: str) -> tuple[int, int, str]: recipe_count = len(recipe_map.get(block_name, set())) loot_count = len(loot_map.get(block_name, set())) - recipe_flag = 0 if recipe_count > 0 else 1 - loot_flag = 0 if loot_count > 0 else 1 - return (recipe_flag + loot_flag, recipe_flag, loot_flag, block_name) + # 使用负数实现降序排序 + return (-recipe_count, -loot_count, block_name) for name in sorted(block_names, key=sort_key): recipe_count = len(recipe_map.get(name, set()))