const obj = {
'anyID2' : {name: 'petya', age: 30},
'anyID1' : {name: 'vasya', age: 20},
'anyID3' : {name: 'kirill', age: 40},
};
const newObj = Object
.keys(obj)
.sort((x, y) => obj[x].age - obj[y].age)
.reduce((acc, key) => { acc[key] = obj[key]; return acc; }, {});
console.log(newObj);
/*
Object { anyID1: {…}, anyID2: {…}, anyID3: {…} }
anyID1: Object { name: "vasya", age: 20 }
anyID2: Object { name: "petya", age: 30 }
anyID3: Object { name: "kirill", age: 40 }
*/