var db = {
"117793766": {
"nick": "Александр",
"balance": 5000
},
"11722333": {
"nick": "Данил",
"balance": 5220
},
"4242422234": {
"nick": "Ноунейм",
"balance": 850
}
}
function getTop(db, n){
return Object
.keys(db)
.sort((a, b) => db[b].balance - db[a].balance)
.slice(0, n)
.map(key => db[key].nick + ' (' + db[key].balance + ')');
}
alert(
getTop(db, 10)
.join('\n'))