fix: improved search result sorting

This commit is contained in:
Jannat Patel
2026-01-01 12:06:15 +05:30
parent edc6007fb6
commit 7a24a83d9e
3 changed files with 104 additions and 82 deletions
+13 -1
View File
@@ -168,10 +168,22 @@ const generateSearchResults = () => {
searchResults.value.push(item)
})
})
//searchResults.value.sort((a, b) => b.score - a.score)
sortResults()
}
}
const sortResults = () => {
searchResults.value.sort((a, b) => {
const dateA = new Date(
a.published_on || a.start_date || a.creation || a.modified
).getTime()
const dateB = new Date(
b.published_on || b.start_date || b.creation || b.modified
).getTime()
return dateB - dateA
})
}
const navigate = (result: any) => {
if (result.doctype == 'LMS Course') {
router.push({