Vivek Vellaichamy
Vivek Vellaichamy

Reputation: 1

how to sort the csv items based on a particular field in freemarker?

Name,RollNo,Height,Weight Adam,10,160,52 Andrew,11,152,40 Brad,12,162,55 Bran,13,161,53

In this case i need to sort the rows based on the Height field. Can you please suggest your answers?

Upvotes: -1

Views: 76

Answers (1)

ddekany
ddekany

Reputation: 31162

I'm not sure how Smooks expose the CSV to the template. If it's a list of rows, where you can read cells in a row like row.Height (like <#list myCsv as row>${row.Height}</#list>), then myCsv?sort_by('Height') should work.

Note however that in general such things should be done outside the template. For more complex cases (even with sorting by multiple fields) you will run into limitations quickly.

Upvotes: 0

Related Questions