You can have a rule fire repeatedly according to a numeric fact property: rule "Rule 03" salience (- $intValue) when $number: Number( $intValue: intValue ) then System.out.println("Number found with value: "+$intValue() ); end
You can't do this with a query. Use some Java method for sorting the collection of facts. Both techniques (not/retract and salience) result in algorithms that perform considerably worse than the best custom sort algorithms. -W On 26 November 2011 18:37, Syargey <syar...@tut.by> wrote: > Hello all, > > I experienced a problem I can't solve. > > After rules firing I got a number of facts of certain type. > > I would like to get a collection of facts sorted by custom field with a > query. > > Drools guide proposes to sort facts by a rule like: > > rule "Rule 03" > when > $number : Number( ) > not Number( intValue < $number.intValue ) > then > System.out.println("Number found with value: "+$number.intValue() ); > retract( $number ); > end > > But it doesn't suit me: > 1) I can't retract facts from session > 2) I need to get sorted collection with a query which doesn't have 'then' > part. > > Is there any method to get custom sorted collection with a query? > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/facts-custom-sort-tp3538410p3538410.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > _______________________________________________ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users >
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users