Sorting a documentList

Can someone please help me to sort a documentList based on a particular value from a field within that documentList??

Hi Ganesh,

Use the service sortDocuments service present in WmPublic to sort the document list based on the key value. Also this service allows you to sort in ascending / descending order based on the key value.

Note: While specifying the key field name, it is sufficient to mention the field name and not the entire path.

Shriraksha A N

Thanks Sriraksha,

But im using wM 6.5.

You got to implement a java service using the API functions I suppose. There is a function sortIDataArrayByKey in IDataUtil class. Just refer the Developer JAVA API docs for more information. Check if the below works in WM6.5

/ pipeline
IDataCursor pipelineCursor = pipeline.getCursor(); 
// documentList
IData[]    documentList = IDataUtil.getIDataArray( pipelineCursor, "documentList" );
String    keyname = IDataUtil.getString( pipelineCursor, "keyname" );
String    compareType = IDataUtil.getString( pipelineCursor, "compareType" );

  if (documentList.length > 0){
        IDataUtil.put(pipelineCursor,"sortedDocumentList", IDataUtil.sortIDataArrayByKey(documentList,keyname,IDataUtil.COMPARE_TYPE_EQUALS,null,false));

    else if(compareType.equals("NUMERIC"))
        IDataUtil.put(pipelineCursor,"sortedDocumentList", IDataUtil.sortIDataArrayByKey(documentList,keyname,IDataUtil.COMPARE_TYPE_NUMERIC,null,false));

    else if(compareType.equals("TIME"))
        IDataUtil.put(pipelineCursor,"sortedDocumentList", IDataUtil.sortIDataArrayByKey(documentList,keyname,IDataUtil.COMPARE_TYPE_TIME,null,false));

    documentList = null;
}catch(Exception e){

    throw new ServiceException(e);

   if(pipelineCursor != null)