I have documents which look like this:
[{
"id": 1,
"title": "the title",
"body": "the body",
},{
"id": 3,
"title": "the title",
"body": "the body",
},{
"id": 2,
"title": "the title",
"body": "the body",
}]
var sortArray = [1,2,3]
I am wondering if it is possible to sort documents from "sortArray", what I mean is in the output the result should be sorted on the basis of the array "sortArray". Can anyone please help me here.
I have tried the below sort with elastic but it's not working.
.Sort(z => sortArray.Count() > 0 ? z.Ascending(q => sortArray.IndexOf(q.id)) : z)