Wm6.5 Sort itemList

Java code was posted regarding this …

#4 09-21-2008, 23:11
abrat13
Member Join Date: Aug 2006

Code Shown at the bottom<<<<<<<<


Issue
I need an entire document sorted and not knowing java I assume this code is sending a sorted document to sortedItemList

Inputs for this service
itemList = mapped the documentReferenceList I am trying to sort
keyField = /itemList/invoiceDetail/customerCode… assuming it is looking for an itemList keyField
sortDescending = ‘sortDescending’

Outputs for this service
sortedItemList = not showing on the results pane
sorted = true

I can see my itemList and the unsorted Values. It does not appear this is doing anything. Code I am using is below.

IData sortedItemList = null;
IDataCursor pipelineCursor = pipeline.getCursor();
IData itemList = IDataUtil.getIDataArray( pipelineCursor, “itemList” );
String keyField = IDataUtil.getString( pipelineCursor, “keyField” );
boolean sortDescending = (Boolean.valueOf(IDataUtil.getString( pipelineCursor, “sortDescending” ))).booleanValue();
pipelineCursor.destroy();
if(itemList != null) {
sortedItemList = IDataUtil.sortIDataArrayByKey(itemList, keyField, IDataUtil.COMPARE_TYPE_COLLATION, null, sortDescending);
}
// pipeline
pipelineCursor = pipeline.getCursor();
IDataUtil.put( pipelineCursor,“sorted”, sortedItemList==null ? “false” : “true”);
pipelineCursor.destroy();

I’m not entirely sure, but I don’t think the key field can be nested within any structure. I think it may need to be a field at the root of each document in the list.

For not being entirely sure you certainly hit this one head on.
I created a new DocumentList with SortKey at the root level and I could not be happier with the results.

As always thanks, thanks, thanks