Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
rooms = {  
    '2B' : [    
        {"RoomEmailId":"2B-323@me.com","RoomName":"2B-323"},    
        {"RoomEmailId":"2B-123@me.com","RoomName":"2B-123"}     
    ],   
    '5A' : [  
        {"RoomEmailId":"5A-323@me.com","RoomName":"5A-323"},   
        {"RoomEmailId":"5A-123@me.com","RoomName":"5A-123"},  
        {"RoomEmailId":"5A-423@me.com","RoomName":"5A-423"}  
    ],  
    '1A' : [  
        {"RoomEmailId":"1A-323@me.com","RoomName":"1A-323"},  
        {"RoomEmailId":"1A-123@me.com","RoomName":"1A-123"},  
        {"RoomEmailId":"1A-423@me.com","RoomName":"1A-423"}  
    ]  
}
const result = Object.keys(rooms).reduce((obj, roomKey) => {
  obj[roomKey] = rooms[roomKey].slice().sort((a, b) => a.RoomName > b.RoomName);
  return obj;
}, {});
console.log(result); // the obj with each array value sorted
console.log(rooms); // note that the original object is unmodified
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers