|
|
@@ -119,24 +119,26 @@ async function runScript() {
|
|
119
|
119
|
|
|
120
|
120
|
// 按年级和学期顺序处理
|
|
121
|
121
|
const sortedKeys = Object.keys(groupedByGradeAndTerm).sort((a, b) => {
|
|
122
|
|
- const [gradeA, termA] = a.split('_');
|
|
123
|
|
- const [gradeB, termB] = b.split('_');
|
|
|
122
|
+ // 提取年级和学期信息
|
|
|
123
|
+ // 键的格式是 "X年级[上下]_[上下]",例如 "九年级上_上"
|
|
|
124
|
+ const gradeA = a.split('_')[0]; // "九年级上"
|
|
|
125
|
+ const termA = a.split('_')[1]; // "上"
|
|
|
126
|
+ const gradeB = b.split('_')[0]; // "九年级上"
|
|
|
127
|
+ const termB = b.split('_')[1]; // "上"
|
|
124
|
128
|
|
|
125
|
|
- // 提取年级数字部分(如 "一年级" -> "一")
|
|
126
|
|
- const gradeNumA = gradeA.replace('年级', '');
|
|
127
|
|
- const gradeNumB = gradeB.replace('年级', '');
|
|
|
129
|
+ // 从年级信息中提取年级数字部分(如 "九年级上" -> "九")
|
|
|
130
|
+ const gradeNumA = gradeA.replace('年级上', '').replace('年级下', '').replace('年级', '');
|
|
|
131
|
+ const gradeNumB = gradeB.replace('年级上', '').replace('年级下', '').replace('年级', '');
|
|
128
|
132
|
|
|
129
|
133
|
// 先按年级排序(从一年级到九年级)
|
|
130
|
134
|
const gradeCompare = gradeOrder.indexOf(gradeNumA) - gradeOrder.indexOf(gradeNumB);
|
|
131
|
|
- //console.log(gradeA+" "+gradeB+"=" +gradeCompare);
|
|
132
|
135
|
|
|
133
|
136
|
if (gradeCompare !== 0) return gradeCompare;
|
|
134
|
137
|
|
|
135
|
|
- //console.log(termA);
|
|
136
|
|
-
|
|
137
|
138
|
// 同年级按学期排序(上在前)
|
|
138
|
139
|
return termA === '上' ? -1 : 1;
|
|
139
|
140
|
});
|
|
|
141
|
+// ... existing code ...
|
|
140
|
142
|
|
|
141
|
143
|
|
|
142
|
144
|
// 确保排序后的键符合预期顺序
|