Using Collection Sort Step
  • Updated on 10 Sep 2015
  • 2 minutes to read
  • Print
  • Dark

Using Collection Sort Step

  • Print
  • Dark

This tutorial demonstrates how to configure and useCollection Sort Step . This step can be found under All Steps [Catalog] > Data > List category in the Flow Designer. This step can implement the desirable sorting logic for the collection of any existent type.

Steps used in this example:

  • GetAll: Integrations > All Integrations > Internal Services > Account Service
  • Collection Sort : All Steps [Catalog] > Data > List
  • Text AAlphabetically Comes Before TextB:

The below image is of the completed example. This example gets all account emails the output from this step is then sorted

Configure The Steps:
Get All:
Add Get All step from Integrations > All Integrations > Internal Services > Account Service category.

Collection Sort Step:
Add Collection Sort Step from the All Steps [Catalog] > Data > List.
Under Inputs > Input Collection , chose Select From Flow then chose GetAll_Output.All EmailAddress.
Notice that there is a filter flow this is where the sorted logic can be configured.  This type of Flow has Start step with First Entity and Second Entity inputs (of your collection Type) .  It also has three End Steps: Entity First Sorts First, Entity Second Sorts First, Entity First and Second Sorted The Same . Between Start and End Steps, build the sorting logic. The way this Flow works is following: It takes Item0 and Item1 from the Array , then runs these two Items through the sorting logic (set of Rules to compare these two Items). Based on the sorting results, configure the order of these two Items. Then, this Flow runs again but second time it sets Item0 in the array based on the first run and takes Item1 and Item2 from the array.
Select Edit to configure this flow.

Text AAlphabetically Comes Before TextB:
For this example the sorting logic will be based on a simple Rule, that will check which string should be placed first in alphabetical order. 
Add Text AAlphabetically Comes Before TextB step from All Steps [Catalog] > Data > Text category.
Configure Inputs to this Rule by choosing the inputs for the FirstEntity by selecting TextA and then for the SecondEntity select TextB.

Connect True outcome from the Rule to the Entity First Sorts First End Step and False outcome to the Entity Second Sorts First End Step .
Then, save the Flow and close Flow Designer.

Connect the Pathways and Debug the Flow:
Connect Done outcome from the Collection Sort step to the End Step in the Flow . This completes the Flow . Select Debug on the top Panel of the Flow Designer to test the Flow .
The Flow runs in the Debugger. Select theCollection Sort Step, onExecution 1 chose View Input/Output Data. Within this dialog the Inputs are visible, as email address that are not sorted. Under the Outputs section its visible that the email addresses are sorted in an alphabetical order. 

Was this article helpful?