JSFiddle - React, Tailwind, and code Playground

by bobbyrne01

HTML

<div id="results">
</div>

JavaScript

var audio = [];
var temp = [];
temp.push({
    dir: '/home/sup',
    filename: 'haha.mp3'
});

audio.push({
    dir: '/home/user',
    filename: 'test2.mp3'
});
audio.push({
    dir: '/home/user',
    filename: 'test1.mp3'
});
audio.push({
    dir: '/home/user/Downloads',
    filename: 'track2.mp3'
});
audio.push({
    dir: '/home/user/Downloads',
    filename: 'track1.mp3'
});
audio.push({
    dir: '/home/user/Music',
    filename: 'track1.mp3'
});

function compare(a,b) {
  if (a.filename < b.filename)
     return -1;
  if (a.filename > b.filename)
    return 1;
  return 0;
}


audio.sort(compare);

temp = audio.slice();

for (var i = 0; i < temp.length; i++){
    document.getElementById('results').innerHTML += temp[i].dir + '/' + temp[i].filename + '<br/>';
}