title: How to sort GSON Array based on a key?
body: <p>Consider the following is my Array</p>
  
  <pre><code>[
    {"id":10,"name":"name10","valid":true},
    {"id":12,"name":"name12","valid":false},
    {"id":11,"name":"name11","valid":false},
    {"id":9,"name":"name9","valid":true}
  ]
  </code></pre>
  
  <p>Created a <code>JsonArray</code> out of it, like following code does:</p>
  
  <pre><code>//Create a JSON Parser using GSON library 
  objJsonParser = new JsonParser();
  String strArrayText = [{"id":9,"name":"name9","valid":true}, ...]
  JsonArray jsonArrayOfJsonObjects = objJsonParser.parse(strArrayText).getAsJsonArray();
  </code></pre>
  
  <p>Now, I am trying to sort <code>jsonArrayOfJsonObjects</code> based on <code>name</code> field. <br/></p>
  
  <p>Desired Output:</p>
  
  <pre><code>[
    {"id":9,"name":"name9","valid":true},
    {"id":10,"name":"name10","valid":false},
    {"id":11,"name":"name11","valid":false},
    {"id":12,"name":"name12","valid":true}
  ]
  </code></pre>
  
  <p>Could anyone help to sort this out with best apporach with respect to Java &amp; Gson?<br/>
  Your inputs are greatly appreciated.</p>