How to sort a json response in vue.js?

0 like 0 dislike
Here is the code I can't figure out how to call the sort if the data are from the file?(write in fact)

{{infos.stops}} TRANSPLANT{{infos.stops}} TRANSPLANT{{infos.stops}} DIRECT
{{infos.origin}}, {{infos.origin_name}}
{{infos.destination_name}}, {{infos.destination}}
import ticketsData from "../assets/tickets.json";export default {name: "tikets",props: ["course", "translate"],data() {return {info: null,isActive: true};},mounted() { =;},methods: {convertCurrency(money) {return money / this.course;}},filters: {money: function(value) {return value.toFixed(2);},computed: {sortedInfo() { =;console.log(;}}}};
by | 92 views

1 Answer

0 like 0 dislike
First, understand what is json. Characteristic a sign of ignorance - when people confuse json and the objects obtained by parsing json'and.

Secondly, why set the value of info takes place in mounted? What prevents to do it right in the data?

Third, you do not understand what computed properties (documentation, then tried to open?). Should return a value and not something they assign.

Fourthly, we need to sort - well sort:

computed: { sortedInfo() { return [].sort((a, b) => { // how to sort it - then you really know better }); }, },

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
3 answers
110,608 questions
257,187 answers
40,796 users