<div id="body">
<div class="listing-item" data-event-date="2017-05-02">2017-05-02</div>
<div class="listing-item" data-event-date="2018-01-07">2018-01-07</div>
<div class="listing-item" data-event-date="2017-06-05">2017-06-05</div>
<div class="listing-item" data-event-date="2018-01-03">2018-01-03</div>
<div class="listing-item" data-event-date="2017-08-08">2017-08-08</div>
</div>
<script>
var body = document.getElementById("body");
var listElms = body.getElementsByClassName("listing-item");
var sortedElms = Array.prototype.slice.call(listElms).sort(function(a, b) {
return a.dataset.eventDate > b.dataset.eventDate
});
for (var i = 0; i < sortedElms.length; i++) {
body.appendChild(sortedElms[i]);
}
</script>