[Vuejs]-VueJS API result order by rank asc

0👍

_.orderBy is probably referring to the orderBy function of the Lodash JavaScript library. You could do it that way, but JavaScript also has a built-in sort function for Arrays.

for your “filteredCoins” function try adding a .sort after your .filter. So it would look something like

return this.data
  .filter(c => c.name.toLowerCase().includes(this.search.toLowerCase());
  .sort((c1, c2) => c1.rank < c2.rank ? c1.rank === c2.rank ? 0 : -1 : 1);

You can find more details about how .sort works on MDN

Leave a comment