I'm trying to sort an array which contains Id and Time,based on time(milliseconds).
Map.sort(function(a,b){return a.Time-b.Time});
for (keys in Map) {
multi.hgetall(Map[key].id+':List');
}
multi.exec(function(err,data){
res.send(data);
});
Its not displaying any data.There are 3 Ids in that array.
I don't know what is res
in your code. And even if you name the variable keys
, you'll get the array indexes in this sentence:
for(keys in Map){...}
Try something like this, using a forEach
iterator:
Map=[{'id':'a', 'Time':90}, {'id':'c', 'Time':30}, {'id':'b', 'Time':66}]
Map.forEach(function(item){
console.log(item);
multi.hgetall(item.id + ':List');
});
multi.exec(function(err, data){
console.log('data', data);
});
It should print some data if the keys a:List
, b:List
and c:List
exist in your redis database.