I have an array of objects with many layers. It looks like this:
var array = [
{
fields: { title: "Some title here" },
sys: { id: "1234" }
},
{
fields: { title: "Another one there" },
sys: { id: "13456" }
},
{
fields: { title: "Final example" },
sys: { id: "234" }
},
{
fields: { title: "Most final thing" },
sys: { id: "4665" }
},
];
Now I want to sort the array based on whether text exists in the fields.title. For example, I have the phrase "Final search". That needs to sort the array so the current array[2] and array[3] move to the top positions because they contain the word "final".
The sort needs to include multiple words though. So if I used the phrase "final example", array[2] would go first because it contains both words, followed by array[3] which only contains "final".
Is this possible and how?
fields.title), so pls edit your question to be more concise.