Skip to content

Commit 6566232

Browse files
committed
Added automatic sorting for the name and image recipes
1 parent 1ddfb1b commit 6566232

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/recipes/name_and_image/NameAndImageRecipe.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,20 @@ export class NameAndImageRecipe<ParsedElement extends NameAndImage> implements R
5757
const headerRow = this.markdownTableFactory.tableRowNode(
5858
headers.map(header => this.markdownTableFactory.textTableCellNode(header))
5959
);
60-
const puzzleRows = puzzles.map(puzzle =>
61-
this.markdownTableFactory.tableRowNode([
62-
this.markdownTableFactory.textTableCellNode(puzzle.name),
63-
this.markdownTableFactory.imageTableCellNode(puzzle.imageLink, 100),
64-
this.markdownTableFactory.textTableCellNode(puzzle.status)
65-
])
66-
);
60+
const puzzleRows = puzzles
61+
.sort((first, second) =>
62+
first.name.localeCompare(second.name, undefined, {
63+
numeric: true,
64+
sensitivity: 'base'
65+
})
66+
)
67+
.map(puzzle =>
68+
this.markdownTableFactory.tableRowNode([
69+
this.markdownTableFactory.textTableCellNode(puzzle.name),
70+
this.markdownTableFactory.imageTableCellNode(puzzle.imageLink, 100),
71+
this.markdownTableFactory.textTableCellNode(puzzle.status)
72+
])
73+
);
6774
const table = this.markdownTableFactory.table(headerRow, puzzleRows);
6875

6976
return this.markdownTableConverter.tableToString(table);

0 commit comments

Comments
 (0)