<div class="js-courses-type" data-loop="4"></div>
<div class="js-courses-type" data-loop="2"></div>
<div class="js-courses-type" data-loop="1"></div>
<div class="js-courses-type" data-loop="3"></div>
<div class="js-courses-type" data-loop="5"></div>
const courses = [...document.querySelectorAll('.js-courses-type')].sort((a, b) => a.getAttribute('data-loop') - b.getAttribute('data-loop'));
courses.forEach( course => window.console.log(course));