cancel
Showing results for 
Search instead for 
Did you mean: 

sorting mapping requirement

Former Member
0 Kudos

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

View Entire Topic
Former Member
0 Kudos

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

anupam_ghosh2
Active Contributor
0 Kudos

Hi Sagarika,

                  Thank you so much for your post, this is indeed a very nice explanation.

Regards

Anupam