Skip to content

Commit 5523f95

Browse files
committed
fix: code review
1 parent 4c719fe commit 5523f95

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

packages/astro/src/default/utils/content.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -293,23 +293,10 @@ function getOrder(order: string[] | undefined, fallbackSourceForOrder: Record<st
293293

294294
function sortCollection(collection: CollectionEntryTutorial[]) {
295295
return collection.sort((a, b) => {
296-
const splitA = a.id.split('/');
297-
const splitB = b.id.split('/');
296+
const depthA = a.id.split('/').length;
297+
const depthB = b.id.split('/').length;
298298

299-
const depthA = splitA.length;
300-
const depthB = splitB.length;
301-
302-
if (depthA !== depthB) {
303-
return depthA - depthB;
304-
}
305-
306-
for (let i = 0; i < splitA.length; i++) {
307-
if (splitA[i] !== splitB[i]) {
308-
return splitA[i].localeCompare(splitB[i]);
309-
}
310-
}
311-
312-
return 0;
299+
return depthA - depthB;
313300
});
314301
}
315302

0 commit comments

Comments
 (0)