title: Changing order of the elements in javascript object according to given key
body: <p>I'm attempting to change the order of the Object in javascript by given key. Here is my code for the same but it says "shift is not a function". Is it not applicable on objects? Please give a solution.</p>
  
  <pre><code>    periods = {
        "Su": 6,
        "Mo": 10,
        "Ma": 7,
        "Ra": 18,
        "Ju": 16,
        "Sa": 19,
        "Me": 17,
        "Ke": 7,
        "Ve": 20,
      };
      rotateOrder(key:any, entities:any) {
              let result = entities;
              for(var k in entities) {
                if(entities.hasOwnProperty(k) &amp;&amp; k != key){
                  result.push(result.shift());
                }
                else {
                  return result;
                }
              }
            }
  console.log(this.rotateOrder("Ve", this.periods));
  </code></pre>