lundi 26 novembre 2018

i need to sort array of objects in **Vue** with to attributes of the object but **Vue** go in infinite loop to sorting

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