I have JSON data that looks something like this:
{
"items":[
{"name":"Dondasch",
"tier":"Rare"
},
{"name":"Elight",
"tier":"Rare"
},
{"name":"Krak",
"tier":"Unique"
}
]
}and I'm looking for a way to sort them by the "Tier: ???". I want to group all "items" that have the same value together, preferably in a way I define (As in, I can choose if the ones with "rare" or "unique" come first, rather than it being alphabetical. After I've sorted them, I need to be able to perform this code on them:
data.items.forEach(wynnitem => {
      const card = document.createElement('div');
      card.setAttribute('class', 'card');
      const h1 = document.createElement('h1');
      $(h1).hide();
      h1.textContent = wynnitem.name;
      if (wynnitem.tier == "Unique") {
        h1.setAttribute('class', 'unique');
      } else if (wynnitem.tier == "Rare") {
        h1.setAttribute('class', 'rare');
      } else if (wynnitem.tier == "Legendary") {
        h1.setAttribute('class', 'legendary');
      } else if (wynnitem.tier == "Mythic") {
        h1.setAttribute('class', 'mythic');
      }
      $(h1).fadeIn(1000);
}):Any other questions I've found just give a way to sort them alphabetically, not by a certain value.
 
     
     
    