The sort pattern is used to sort the contents of a message body, assuming that the message body contains a list of items that can be sorted.
By default, the contents of the message are sorted using a default comparator that handles
numeric values or strings. You can provide your own comparator and you can specify an
expression that returns the list to be sorted (the expression must be convertible to
java.util.List).
The following example generates the list of items to sort by tokenizing on the line break character:
<route> <from uri="file://inbox"/> <sort> <simple>body</simple> </sort> <beanRef ref="myServiceBean" method="processLine"/> </route>
To use a custom comparator, you can reference it as a Spring bean:
<route> <from uri="file://inbox"/> <sort comparatorRef="myReverseComparator"> <simple>body</simple> </sort> <beanRef ref="MyServiceBean" method="processLine"/> </route> <bean id="myReverseComparator" class="com.mycompany.MyReverseComparator"/>
Besides simple, you can supply an expression using any language
you like, so long as it returns a list.








