cancel
Showing results for 
Search instead for 
Did you mean: 

How sort collection by multiple fields

vinodchinthakin
Level 9
Hi All , Any one can suggest how to Sort Collection for Multiple conditions. For Example Filed1 needs to be Sorted as "Ascending" and Filed2 needs to be Sorted as "Descending" at once. I was able to achieve in Excel(which is called as Custom Sort). How to apply Custom Sorting in BP Collection?

Thanks​​

------------------------------
vinod chinthakindi
------------------------------
1 BEST ANSWER

Helpful Answers

Carl__Carter
Staff
Staff
Hi Vinod,

You can copy the Sort action in the 'Utility - Collection' business object into a new Action.

Once done, delete the Ascending Order action input and data item, as these are not required for the new action.

Adjust the code start to match the below:

28745.png
When you call the Action, the [Sort Field] Input Parameter would list the fields to sort by and their order. Each field separated by a comma. For example:

[FieldName1] ASC, [FieldName2] DESC


------------------------------
Carl Carter
Senior Developer
Blue Prism
Europe/London
------------------------------

View answer in original post

4 REPLIES 4

Carl__Carter
Staff
Staff
Hi Vinod,

You can copy the Sort action in the 'Utility - Collection' business object into a new Action.

Once done, delete the Ascending Order action input and data item, as these are not required for the new action.

Adjust the code start to match the below:

28745.png
When you call the Action, the [Sort Field] Input Parameter would list the fields to sort by and their order. Each field separated by a comma. For example:

[FieldName1] ASC, [FieldName2] DESC


------------------------------
Carl Carter
Senior Developer
Blue Prism
Europe/London
------------------------------

Thanks Carl, It's worked excellent.!

------------------------------
vinod chinthakindi
------------------------------

Hi
Can you share complete start, end, code properties for this?

@pmittal 

There is a little trick to turn the Sort Collection action in Blue Prism's Utility - Collection Manipulation VBO into a multi-column sorter. You simply list out your columns and their sort directions separated by a comma but leave out the sort direction of the last column. Set the Ascending Order parameter accordingly to the sort direction of that last column.

MichealCharron_0-1716842662646.png

The Sort Collection action does essentially the same thing as the code in the replies above but it adds either " ASC" or " DESC" to the Sort Field string depending on how the Ascending Order parameter is set.

 

Micheal Charron
RBC
Toronto, Ontario
Canada