What else can be done to sort the title
of a binary array?
let ary = [
["search-type", [{
"title": "google",
"link": "https://"
},
{
"title": "wikipedia",
"link": "https://"
},
{
"title": "a-search",
"link": "https://"
},
{
"title": "c-search",
"link": "https://"
},
{
"title": "q-search",
"link": "https://"
}
]],
["tool-type", [{
"title": "remove bg",
"link": "https://"
},
{
"title": "q",
"link": "https://"
},
{
"title": "c",
"link": "https://"
},
{
"title": "3q",
"link": "https://"
}
]]
];
ary.forEach(array => {
array[1].sort(function(s, t) {
let a = s.title.toLowerCase();
let b = t.title.toLowerCase();
if (a < b) return -1;
if (a > b) return 1;
return 0;
})
})
console.log(ary);