I have listOfChapters(see in below code) now this array title I print using map so that is print like this chapter1, chapter2, chapter-3, chapter -4 but i want to print in the sequence of weight how to possible this ?
weight
listOfChapters.map(x => x.title) // current output is chapter-1 1
chapter-2 3
chapter-3 2
chapter-4 0
// Exprected output using weight sequence chapter-4 0
chapter-1 1
chapter-3 2
chapter-2 3
listOfChapters = [
0: {id: 242, title: "Chapter - 1", weight: 1}
1: {id: 261, title: "Chapter - 2", weight: 3}
2: {id: 262, title: "Chapter - 3", weight: 2}
3: {id: 263, title: "chapter - 4", weight: 0}
]