How to sort DocumentList in Wm65

Looking for quick response:-
I have a documentlist in that there are numbers of documents each documents contain several number of records which contains several number of fields.
I need to sort the document on one of the field (example field name:-xyz).
Please let me know how to do this. I am using webMethods 6.5.

Is there any inbulit service or util service which can be use to reslove this issue?
if there is no built in service in WM6.5 then i guess i need to write java service to sort record in documentList.
as i am not good in java service plz help me out to resolve this issue.
or plz paste java code to sort record in dcoumentlist

Appriciate your response

Thanks
Rajesh

There is a sortDocumentListByKey service in the PSUtilities package. It may not be exactly what you need, but it is a Java service and should give you a good start.

Hi PhilLeary

are you taking about WM6.1 basically i am using WM6.5 i didn’t find any java service name called sortDocumentListByKey in PSUtilities package…
Thanks for quick reply…

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();

Key is IDataUtil.sortIDataArrayByKey …use it as you like…

hi abrat13
is this full java code?
This java code is use for sorting documentlist?
as i have very poor knowledge of java …plz reply back

rj40565,

Abrat’s post is full java service code. Create a java service with inputs of itemList (which should be a DocumentList) and keyField (which should be a string), and sortDescending(which should be a string); and an output of sorted (which should be a DocumentList).

Paste abrat’s code into your Java service.

Save to compile it, then use it in your flow. Map your documentList to sort to itemList, specify the field to sort on, and then true or false for sortDescending.

Phil

Thanks Phil for explaining it…

rj40565 please follow steps as per Phils explaination…

Cheers,
Ajit