Sort menu items: active first, then by price asc, then by number

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
František Musil
2026-05-12 09:45:40 +02:00
parent a37b3e848d
commit ad6094898c
+3
View File
@@ -39,6 +39,8 @@ function formatMenu(menu: ParsedMenu): string {
}
const sorted = [...menu.items].sort((a, b) => {
if (a.inactive !== b.inactive) return a.inactive ? 1 : -1
if (a.price !== b.price) return a.price - b.price
const na = parseInt(a.name.match(/^(\d+)\./)?.[1] ?? "99", 10)
const nb = parseInt(b.name.match(/^(\d+)\./)?.[1] ?? "99", 10)
return na - nb
@@ -58,6 +60,7 @@ async function tg(text: string): Promise<void> {
return
}
await sendMessage(config.telegram.botToken, config.telegram.chatId, text)
console.log(`TG sent: ${text.slice(0, 80)}${text.length > 80 ? "…" : ""}`)
}
async function main() {