function placeGuests (arr) {
let result = [arr[0]];
let currentUser = arr[0];
while(arr.length!==result.length){
arr.forEach(el => el.close.sort((a,b) =>
a > b ? 1 : -1
))
let closeFilter = currentUser.close.filter(closeName =>
!result.find(friend =>
closeName === friend.name))
let user = arr.find(el => el.name === closeFilter[0])
currentUser = user
result.push(user)
}
return result;
}
Я такой код написал) Всех с Новым годом!