title: Sorting a list of objects using Drools rules engine
body: <p>I am trying to sort a list of objects using a set of rules defined in drools rules engine.
  The sample object structure is as follows</p>
  <pre class="lang-java prettyprint-override"><code>public class A {
  
     String name;
     Date createdDate;
  
  }
  </code></pre>
  <p>I want to <br/></p>
  <ol>
  <li><p>Define a set of rules for sorting a list of objects .<br/>
  Ex : <strong>rule 1 : &quot;Sort objects using name ascending&quot;</strong><br/>
         <strong>rule 2 : &quot;Sort objects using createdDate descending&quot;</strong></p>
  </li>
  <li><p>Define the order which the rules needs to be executed .<br/>
  Ex : <strong>set order 1 to rule 1</strong> <br/>
         <strong>set order 2 to rule 2</strong> <br/>
  So the objects will be sorted  by  name ascending  and createdDate descending.</p>
  </li>
  </ol>
  <p>Can I achieve this using the drools engine ? <br/>
  I thought of using the compareTo() for the sorting but since the sorting criteria can be changed
  at runtime the logic is becoming complex and  hard to maintain.</p>
  <p>Thanks, <br/>
  <strong>Kolitha</strong>.</p>