implemented server side sort

This commit is contained in:
Sven Roman Reinhard 2026-03-10 04:23:49 +01:00
parent 2793b54b5b
commit 5148502da7
2 changed files with 27 additions and 25 deletions

View file

@ -1140,8 +1140,14 @@ class LibraryController {
})
}
// sorting
const key = req.query.sortBy === 'numBooks' ? 'numBooks' : 'name';
const order = req.query.sortOrder === 'desc' ? 'desc' : 'asc';
const narratorArr = Object.values(narrators);
const sorted = naturalSort(narratorArr)[order]((n) => n[key])
res.json({
narrators: naturalSort(Object.values(narrators)).asc((n) => n.name)
narrators: sorted
})
}