Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit bd27a813 authored by FadhilP's avatar FadhilP
Browse files

sort threads in topics by id's

parent 91c7aa74
Branches
No related tags found
No related merge requests found
......@@ -18,7 +18,12 @@ export default function Topic(props){
const topic = responseTopics.data.data.find(topic => topic.name === topicParam).id
const threads = responseThreads.data.data.filter(thread => thread.topic_id === topic)
setThread(threads)
const sortedThreads = threads.sort((a, b) => {
if (a.id < b.id) return 1
if (a.id > b.id) return -1
return 0
})
setThread(sortedThreads)
console.log(threads)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment