vue js sort array of object with attribute and try to sort that sorted array with another attribute but Vue go in infinite loop of sorting
chatRoomArraySorted: function(){
console.log("func name chatRoomArraySorted");
function compare(a, b) {
if (a.name < b.name)
return -1;
if (a.name > b.name)
return 1;
return 0;
}
return this.chatRoomsArray.sort(compare);
}
sortedArray: function() {
this.log("sortedArray");
function compare1(a, b) {
return new Date(b.lastMsg.createdAt) - new Date(a.lastMsg.createdAt);
}
return this.chatRoomsArray.sort(compare1);
},
Aucun commentaire:
Enregistrer un commentaire