cardShop is a div with children -> (images with different ID's and values) every card value looks like this 2000,500 or this 1500,200 I want to sort the images by value in ascending order by the first number in the array. The function is called by the blue button in the right corner.
Here is what I have done so far.
HTML DOC
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="script.js"></script>
<style>
#toSort{
background-color: #3b5998;
width:50px;
height:50px;
float:right;
}</style>
</head>
<body>
<div id = "cardShop" style="overflow:scroll">
<div id ="toSort" onclick="sorting()"></div>
<img id="card" height="400" width="250" src="./cardImages/blueEyes.jpg" value = 3000,2500>
<img id="card2" height="400" width="250" src="./cardImages/blue.jpg" value = 1400,1200>
<img id="card3" height="400" width="250" src="./cardImages/orange.jpg" value = 1200,700>
<img id="card4" height="400" width="250" src="./cardImages/blackDrag.jpg" value = 3200,2500>
<img id="card5" height="400" width="250" src="./cardImages/spider.jpg" value = 2500,2100>
<img id="card6" height="400" width="250" src="./cardImages/dark.jpg" value = 2500,2100>
<img id="card7" height="400" width="250" src="./cardImages/grill.jpg" value = 2000,1700>
<img id="card8" height="400" width="250" src="./cardImages/gaia.jpg" value = 2300,2100>
<img id="card9" height="400" width="250" src="./cardImages/redEyes.jpg" value = 2400,2000>
<img id="card10" height="400" width="250" src="./cardImages/flamee.jpg" value = 1800,1600>
<img id="card11" height="400" width="250" src="./cardImages/curse.jpg" value = 2800,2200>
<img id="card12" height="400" width="250" src="./cardImages/tripple.jpg" value = 4500,3800>
</div>
</body>
</html>
JavaScript file
function sorting() {
let deck = [].slice.call(document.getElementById("cardShop").children)
for (let i = 2; i < deck.length; i++) {
let elementValue = deck[i].getAttribute('value').split(",").map(Number);
}
}