title: How to reorder JSON based on desired rule (not by its name or index)?
body: <p>I have a JSON and want it to be reordered into a new JSON.</p>
  <p>This is how I get my JSON:</p>
  <pre><code>function getFormData($form){
  
     var unindexed_array  = $form.serializeArray();
     var indexed_array    = {};
  
     $.map(unindexed_array, function(n, i){
         indexed_array[n['name']] = n['value'];
     });
  
     return indexed_array;
  }
  </code></pre>
  <p>Let's say the result is like this (JSON.stringify()):</p>
  <pre><code>var txt_JSON = {&quot;username&quot;:&quot;john&quot;,&quot;email&quot;:&quot;john@doe.com&quot;,&quot;age&quot;:&quot;29&quot;,&quot;created_date&quot;:&quot;2020-10-28&quot;}
  </code></pre>
  <p>I'd like to reorder it by custom. Something like this:</p>
  <pre><code>var arr_order = [3,2,0,1];
  </code></pre>
  <p>Based on the reorder rule, the JSON should change into like this:</p>
  <pre><code>var txt_JSON = {&quot;created_date&quot;:&quot;2020-10-28&quot;,&quot;age&quot;:&quot;29&quot;,&quot;username&quot;:&quot;john&quot;,&quot;email&quot;:&quot;john@doe.com&quot;}
  </code></pre>
  <p>Most of the example here show sorting by name or value. Any help is greatly appreciated.</p>