From f31ea55ca06b9202adebfb0344be85a95d0af697 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Tue, 19 Aug 2025 23:06:46 +0300 Subject: [PATCH] Fixed order by and sorting --- ui/app/components/YTDLPOptions.vue | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ui/app/components/YTDLPOptions.vue b/ui/app/components/YTDLPOptions.vue index 5ca1470b..2d23f5b2 100644 --- a/ui/app/components/YTDLPOptions.vue +++ b/ui/app/components/YTDLPOptions.vue @@ -267,12 +267,16 @@ const grouped = computed<{ name: string, items: YTDLPOption[] }[]>(() => { map.get(key)!.push(o) } - const out = Array.from(map.entries()).map(([name, items]) => { - items.sort((a, b) => (a.flags[0] || '').localeCompare(b.flags[0] || '')) - return { name, items } - }) + const dir = 'asc' === sortDir.value ? 1 : -1 + const out = Array.from(map.entries()).map(([name, items]) => ({ 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 })