title: How to order an array of objects according to different properties?
body: <p>I need to order an array where the elements are objects. I want to fill up a dropdown in a specific order</p>
  
  <pre><code>[{ id: 1, name: "Country", parent: null, level: 0 }, 
  { id: 48, name: "Village1", parent: 16, level: 2 }, 
  { id: 17, name: "City1", parent: 1, level: 1 }, 
  { id: 15, name: "Village4", parent: 16, level: 2 }, 
  { id: 61, name: "City2", parent: 1, level: 1 }, 
  { id: 16, name: "City3", parent: 1, level: 1 }, 
  { id: 85, name: "City6", parent: 1, level: 1 }, 
  { id: 31, name: "Village2", parent: 77, level: 2 }, 
  { id: 76, name: "City4", parent: 1, level: 1 }, 
  { id: 77, name: "City5", parent: 1, level: 1 }, 
  { id: 79, name: "Village3", parent: 77, level: 2 }]
  </code></pre>
  
  <p>What I am trying to achieve is to to get a dropdown where first appear the Country (parent null), then its children, but immediately, if those children have also children, they should appear down below, kind of:<br>
  - Country<br>
  - City1<br>
  - City2<br>
  - City3<br>
  - Village1<br>
  - Village2<br>
  - City4<br>
  . . .
  And so on..</p>
  
  <p>Anyone can give me a hand? I am really struggling here...</p>