on 09-19-2012 2:29 AM
Hi,
I am working on JDBC to File scenario and my requirement is very simple
Input:
<row>
<DeliveryNumber>50</DeliveryNumber>
<DeliveryCreationDate>20121001</DeliveryCreationDate>
<FirstName>20121001</FirstName>
<CustomerName>John Miller</CustomerName>
<row>
<row>
<DeliveryNumber>10</DeliveryNumber>
<DeliveryCreationDate>20121001</DeliveryCreationDate>
<FirstName>20120901</FirstName>
<CustomerName>John Mike</CustomerName>
<row>
<row>
<DeliveryNumber>5</DeliveryNumber>
<DeliveryCreationDate>20121001</DeliveryCreationDate>
<FirstName>20121004</FirstName>
<CustomerName>Swanny</CustomerName>
<row>
<row>
<DeliveryNumber>5</DeliveryNumber>
<DeliveryCreationDate>20121001</DeliveryCreationDate>
<FirstName>Swanny</FirstName>
<CustomerName>swanny</CustomerName>
<row>
now i need sort the records based on Delivery Number.
Expected output
<row>
<DeliveryNumber>5</DeliveryNumber>
<DeliveryCreationDate>20121001</DeliveryCreationDate>
<FirstName>20121004</FirstName>
<CustomerName>Swanny</CustomerName>
<row>
<row>
<DeliveryNumber>5</DeliveryNumber>
<DeliveryCreationDate>20121001</DeliveryCreationDate>
<FirstName>Swanny</FirstName>
<CustomerName>swanny</CustomerName>
<row>
<row>
<DeliveryNumber>10</DeliveryNumber>
<DeliveryCreationDate>20121001</DeliveryCreationDate>
<FirstName>20120901</FirstName>
<CustomerName>John Mike</CustomerName>
<row>
<row>
<DeliveryNumber>50</DeliveryNumber>
<DeliveryCreationDate>20121001</DeliveryCreationDate>
<FirstName>20121001</FirstName>
<CustomerName>John Miller</CustomerName>
<row>
i tried using sort fucntion with combination remove context and split value but did not worked.
Cheers,
John
Hi John,
As the functions sort and sortByKey only sort the elements within the same context, we have to use the function removeContexts before sort. After sort we have to restore the original contexts. We do this with the node function splitByValue .
Please find the below example:
I sort the records based on EMPID.
Final output:
Best Regards,
Sagarika
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
For deliveryNumber use the normal sort function:
deliveryNumber -> removeContext -> sort: desc-> splitByValue:each -> deliveryNumber
And for the other items, you need to use sortByKey:
deliveryNumber ->removeContext -> sortByKey: desc -> splitByValue:each -> deliveryCreationDate
deliveryCreationDate -> removeContext -> /
And so on...
Hope this helps,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.