window.addEventListener('DOMContentLoaded', () => {
    sortcontent();
})
function sortcontent(){
    const numbers =[];
    const numbers1=new Map();
    var liczba=0;
    document.querySelectorAll('.dendro-art .blog-items h2 a').forEach(dendro => {
        var numb=dendro.innerHTML;
     numbers.push(numb);
     
     
    })
    try{numbers.sort(compareNumbers);}catch(error){}
    
    
    numbers.forEach( (element) => {
        liczba++;
        numbers1.set(liczba,element);
    })
    
document.querySelectorAll('.grid-dendrocontent .blog-item').forEach(dender => {
    numbers1.forEach( (value,key) => {

        if(dender.innerHTML.includes(value)){
            dender.style.setProperty('order',key);

        }

    })
          
})
  
   
}


function compareNumbers(a, b) {
    const aStart = parseInt(a.split(': ')[1].split('-')[0]);
    const bStart = parseInt(b.split(': ')[1].split('-')[0]);
    return aStart - bStart;
  }