I am working on this code and need to sort the JSON output by a value, in this case called cars. How can I accomplish it in this code?
var txtFile = new XMLHttpRequest();
txtFile.open("GET", "test.txt", true);
txtFile.onreadystatechange = function() {
if (txtFile.readyState === 4) {
if (txtFile.status === 200) { // Makes sure it's found the file.
allText = txtFile.responseText;
lines = txtFile.responseText.split("\n"); // Will separate each line into an array
for (var i = 0; i <= lines.length; i++){
var obj = JSON.parse(lines[i]);
document.getElementById("demo").innerHTML += obj._serverMessages[0].car + " " + obj.creator.substr(2, obj.creator.length) + " / " + obj._serverMessages[0].content + "<br>";
}
}
}
}
txtFile.send(null);