Вот таким должен быть index.js
function mySort() {
let sorty = document.querySelector('.goods-wrap');
for (let i = 0; i < sorty.children.length; i++) {
for(let j = i; j < sorty.children.length; j++){
if(+sorty[i].getAttribute('data-price') > +sorty.children[j].getAttribute('data-price')) {
replacedNode = sorty.replaceChild(sorty.children[j], sorty.children[i]);
insertAfter(replaceNode, sorty.children[i]);
}
}
}
}
function insertAfter(elem, refElem) {
return refElem.parentNode.insertBefore(elem, refElem.nextSibling);
}
document.addEventListener('DOMContentLoaded', ()=> {
document.querySelector('.sorted-price').onclick = mySort;
})