title: How to iterate over jcr nodes in specific order?
body: <p>I was working around with the iterator to list and traverse over child nodes and I'm getting this anomalous behavior where the iterator lists the nodes in different order each time. I need to iterate over nodes as it's present in the crx/de. Is there a way it could be done, to control the order of listing!</p>
  
  <pre><code>Map&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  map.put("path", getResource().getPath());
  map.put("1_property", "sling:resourceType");
  map.put("1_property.operation", "equals");
  map.put("1_property.value", "/path/to/some/node");
  
  QueryBuilder queryBuilder = 
                 getResourceResolver().adaptTo(QueryBuilder.class);
  Query query = queryBuilder.createQuery(PredicateGroup.create(map),
                 getResourceResolver().adaptTo(Session.class));
  SearchResult result = query.getResult();
  </code></pre>
  
  <p>In the iterator below what I'm getting in <code>Resource next</code> is the resource nodes in some random order.</p>
  
  <pre><code>Iterator&lt;Resource&gt; resources = result.getResources();
  while (resources.hasNext()) {
      Resource next = resources.next();
      //The operations
  }
  </code></pre>
  
  <p>It should be iterated as it's present in the crx, instead it's taking the order exclusiveofferboxes__3, exclusiveofferboxes__1, exclusiveofferboxes__2.</p>
  
  <p><a href="https://i.stack.imgur.com/OL4ft.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OL4ft.png" alt="enter image description here"></a></p>