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
public class A {
String name;
Date createdDate;
}
I want to
Define a set of rules for sorting a list of objects .
Ex : rule 1 : "Sort objects using name ascending"
rule 2 : "Sort objects using createdDate descending"Define the order which the rules needs to be executed .
Ex : set order 1 to rule 1
set order 2 to rule 2
So the objects will be sorted by name ascending and createdDate descending.
Can I achieve this using the drools engine ?
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.
Thanks,
Kolitha.