Fixed order by and sorting

This commit is contained in:
arabcoders 2025-08-19 23:06:46 +03:00
parent 89d4c026c5
commit f31ea55ca0

View file

@ -267,12 +267,16 @@ const grouped = computed<{ name: string, items: YTDLPOption[] }[]>(() => {
map.get(key)!.push(o) map.get(key)!.push(o)
} }
const out = Array.from(map.entries()).map(([name, items]) => { const dir = 'asc' === sortDir.value ? 1 : -1
items.sort((a, b) => (a.flags[0] || '').localeCompare(b.flags[0] || '')) const out = Array.from(map.entries()).map(([name, items]) => ({ name, items }))
return { name, items }
}) if ('group' === sortBy.value) {
out.sort((a, b) => a.name.localeCompare(b.name) * dir)
} else {
// When sorting by flag, groups should still be in alphabetical order
out.sort((a, b) => a.name.localeCompare(b.name))
}
out.sort((a, b) => a.name.localeCompare(b.name))
return out return out
}) })
</script> </script>