diff --git a/app/api/leantime/status-labels/route.ts b/app/api/leantime/status-labels/route.ts index b00f5780..3354f412 100644 --- a/app/api/leantime/status-labels/route.ts +++ b/app/api/leantime/status-labels/route.ts @@ -123,7 +123,7 @@ export async function GET() { name: label.name, statusType: label.statusType, class: label.class, - sortKey: label.sortKey, + sortKey: Number(label.sortKey) || 0, // Convert to number, default to 0 if invalid projects: [] }); } @@ -134,9 +134,9 @@ export async function GET() { }); }); - // Convert the map to an array and sort by sortKey + // Convert the map to an array and sort by sortKey numerically const transformedLabels = Array.from(uniqueLabels.values()) - .sort((a, b) => (a.sortKey || '').localeCompare(b.sortKey || '')); + .sort((a, b) => a.sortKey - b.sortKey); return NextResponse.json({ statusLabels: transformedLabels }); } catch (error) {