Thank you, trad-ex. But that is not what I am looking for. I am aware of "velocityCount", but it is not what I need.

Outside of my collection, I need to generate a value on which to sort. The field that I want to sort by has values of AB-1, AB-2, AB-3, etc. When the values get above AB-9, direct sorting does not work. AB-10, AB-11, AB-12, etc. come before AB-2. So, I need to manipulate these values outside of the collection, then add them back in.

Thanks for your reply.

gmc

trad-ex wrote:
Hi Gary,

You mean "velocityCount" ?
It should be set in velocity.properties like:

directive.foreach.counter.name = velocityCount
directive.foreach.counter.initial.value = 1


using like below:
#foreach( $i in $list )
  $i is the number of $velocityCount
#end

HTH

Best Regards,
trad-ex


Hello all,

I have data stored in a collection. There is no field within the collection that is suitable for use as a sorting parameter. Externally, I can generate this sorting index, but I need a means for adding this index into my collection.

I know how to scan through records, obtain the correct ones, and insert them into a new collection. I also know how I can generate the value of the required index. However, I don't know how to associate the index with the appropriate record in the new collection.

Below is my current code for scanning, choosing the valid records and including them into the new collection. Any help on how to include the index value would be appreciated

#set ($newcollection = [])
#foreach ($rec in $data.collection)
#if($rec.name == "valid") ## choose on valid records #set ($index = ???) ## calculate index value #set ($n = $newcollection.add($rec)) ## add record and index to new collection
      #end
#end

Then, I would like to be able to retrieve the records as follows:

#foreach ($newrec in $SortTool.sort($newcollection, "index") ## choose records from new collection, sorted by "index"


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to