There is a variable containing an array of objects. When you click on the checkbox , the objects are sorted according to the first letter in the meaning of one of the keys. That is, sorted alphabetically.
BUT. How to make it so that when you click again (when the checkbox accepts false ), the array of objects comes to its original form?
new Vue({ el: '.townsProject', data: { towns: [{ town: Moscow, yearvisited: 2015 }, { town: Saint - Petersburg, yearvisited: 2019 }, { town: Novorossiisk, yearvisited: 2016 } ] }, methods: sort: function() { this.towns.sort(function(a, b) { if (a.town > b.town) { return 1; } if (a.town < b.town) { return -1; } return 0; }) } <div class="townsProject"> <input class="container__movieList__seen" type='checkbox' id='sort2' v-on:click="sort()"> <label for='sort2'>Отсортировать по алфавиту</label> </div>