Card sort
Note - under development
cardsort.html
<img id="card1"> <img id="card2"> <img id="card3"> <img id="card4"> <img id="card5"> <button onclick="flip()">Flip</button> <script src="https://digisoln.com/resources/cards.js"></script> <script src="cardsort.js"></script>
cardsort.js
reset(); shuffle(); function flip(){ var hand=[]; //deal cards for array: for(var i = 0; i < 5; i++){ hand[i] = deal_card(); } //sort by suit: hand.sort((a, b) => a.suit.localeCompare(b.suit)); //sort by card weight: hand.sort(function(a, b){return a.weight-b.weight}); document.getElementById("card1").src = hand[0].url; document.getElementById("card2").src = hand[1].url; document.getElementById("card3").src = hand[2].url; document.getElementById("card4").src = hand[3].url; document.getElementById("card5").src = hand[4].url; }This isnt quite right yet but does illustrate the ability to sort complex data types by strings or integers