<ul id="test"></ul>
var data = [
{
'id': 1,
'name': 'İstanbul'
},
{
'id': 2,
'name': 'Çanakkale'
},
{
'id': 4,
'name': 'Ümraniye'
},
{
'id': 3,
'name': 'Ankara'
},
{
'id': 5,
'name': 'Van'
}
];
data = data.sort(function(a,b){
return a.name.localeCompare(b.name);
});
data.forEach(function(key){
var node = document.createElement("LI"),
textnode = document.createTextNode(key.name);
node.appendChild(textnode);
document.getElementById('test').appendChild(node);
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.