I have a JSON object that is sorted alphabetically based on the value rather than the key. However when I use _.each
to inject the object into the form $select
, the object is resorting it based on the key. Does anyone know how I can prevent this.
var $select = $("#tunnel-list");
var tpl = _.template('<option value="<%= id %>"><%= name %></option>');
_.each(tunnels, function(name, index) {
console.log(name, index)
$select.append(tpl({id: index, name: name}));
});