title: Sort object by key in descending order
body: <p>This is simple yet most painful question for me.</p>
  
  <p>Take an example of following snippet of code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const test = {};
  test[2] = 'value2';
  test[1] = 'value1';
  console.log(test);</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>The result of above snippet is:</strong></p>
  
  <pre><code>{
    1: "value1",
    2: "value2"
  }
  </code></pre>
  
  <p><strong>I want to pass this object as it is with following result:</strong></p>
  
  <pre><code>{
    2: "value2",
    1: "value1"
  }
  </code></pre>
  
  <p><strong>PS:</strong> I tried <strong>Object.keys(test).sort()</strong> and <strong>Object.keys(test).reverse()</strong> and then chained it with function for re-creating the object but nothing seems to be working for me.</p>