title: Modification of array objects
body: <p>I am trying to rebuild an array ,so I need suggestion on doing it using best practices.
  I have an array object as follows:</p>
  
  <pre><code>MainObject:
  0:"Namebar"
    1: Object
      Name: "Title1"
      Url: "Url1"
    2: Object
      Name: "Title2"
      Url: "Url2"
    3: Object
      Name: "Title3"
      Url: "Url1"
  </code></pre>
  
  <p>In the above since the "url" is same , I want to group it same object and I am expecting the output in the following format:</p>
  
  <pre><code>0: "Url1"
    1: Object
      Name : "Title1"
      Url: "Namebar"
    2: Object
      Name : "Title3"
      Url: "Namebar"
  
  1: "Url2"
    1: Object
      Name : "Title2"
      Url: "Namebar"
  </code></pre>
  
  <p>I am trying to have two arrays and loop through the MainObject for swapping the items which I know is not only a teadious process but very much high on time complexity.
  For example like  :</p>
  
  <pre><code>var extract1 = MainObject[0];
  var extract2 = using for loop to extract and swap ......
  </code></pre>
  
  <p>I am not getting any other way of achieving this. Any approach for this in javascript/jquery?</p>