function sort(type) {
$("#parentDiv").empty();
$.getJSON("raw_data.json", ({ Search }));
function Sear(a, b) {
return (a[Search.type] < b[Search.type]) ? -1 : (a[Search.type] > b[Search.type]) ? 1 : 0;
};
}
我的raw_data.json
将是here。
虽然我已宣布搜索。它出现了一个错误:
未定义搜索。
答案 0 :(得分:0)
function sort(type) {
$("#parentDiv").empty();
$.getJSON("raw_data.json", ({ Search }) => {
Search.sort(function(a,b){
if(a[type]<b[type]){return -1;}
else if(a[type]>b[type]){
return 1;
}
else {
return 0;
}
});
console.log(`Sorted by: ${type}`);
console.log("movies are displayed!!");
var i;
... code