фонарик,
materials = {"Глина" : 10, "Цемент" : 5, "Вода" : 8, "Песок" : 14}
sort_arr = ["Красители", "Песок", "Цемент", "Вода", "Примеси"]
sort = function(object, pattern){
var result={};
Object.keys(object).sort(function(a,b){
var aa = pattern.indexOf(a), bb = pattern.indexOf(b);
if ( aa != -1 && bb != -1) return aa - bb ;
if ( aa == -1 && bb == -1) return a < b ? 1 : a > b ? -1 : 0;
if ( aa == -1 && bb != -1) return 1;
if ( aa != -1 && bb == -1) return -1;
}).forEach(function(name){
result[name]=object[name]
})
return result
}
materials=sort(materials, sort_arr)
alert(JSON.stringify(materials))
for (n in materials){
console.log(n+" "+materials[n])
}
//>>>> {"Песок":14,"Цемент":5,"Вода":8,"Глина":10}