I have an array of objects:
var data= [{
"title": "All pages",
"page": "all",
}, {
"title": "Post with builder",
"page": "pt_post_6188",
}, {
"title": "Blog Categories",
"page": "tx_category",
}, {
"title": "Single Blog Posts",
"page": "pt_post",
}];
and a sorting order array constructed out of the object item titles.
var order = ["Post with builder", "All pages", "Blog Categories", "Single Blog Posts"];
how do I sort the first array by the order array so that the new data turns out like this
var newdata= [{
"title": "Post with builder",
"page": "pt_post_6188",
}, {
"title": "All pages",
"page": "all",
}, {
"title": "Blog Categories",
"page": "tx_category",
}, {
"title": "Single Blog Posts",
"page": "pt_post",
}];
?
Not same as ref post. I am sorting by a specific order array without any specific logic.