Sort Custom

Sort Custom allows you to do a custom sort of a list by calling another Flow to generate the value used to sort each item. For simple sorts, use the Sort function instead.

To use this function, you'll need another Flow that calculates the sort value for an item. Define fields on the event card that will be the inputs that are required to determine the sort value. Typically you will include a field for the item of the list, i.e. if the list is a list of text then one of the inputs should be text. You can also include as other inputs whatever your Flow will need to calculate the sort value. If you need to know the position of the current item inside the list, use the "Index" field from the Context section of the child Flow card. Then build the rest of the child Flow, ending with a Return card that returns a single value. The name for the value on the Return card doesn't matter. Save the Flow and turn it on.

Now go back to the Sort Custom card, input the list you want to sort, and then select the Flow you just built.  The inputs will auto-populate, then you can map data into them. To map an input to accept each item of the list, click in that field and you will see a dropdown that includes Item - select that.  Or if your list is a list of objects, you may also see the schema of the object, i.e. the keys that it contains, and  you can also build your child Flow to accept those as inputs. In addition, you can drag in outputs from previous cards in the Flow - in that case, the same value will be used for each item in this list.

Input Fields

  • list: The input list that contains all of the items you want to sort

  • flow:  The child Flow that will be called once for each item in the list

  • with the following values (dynamically generated):  The inputs defined by the child Flow - these will populate after you select the child Flow using the Choose Flow dialog

  • concurrency:  The number of items in the list to process in parallel.  If it is important that the items are processed in sequence, use 1.  Otherwise a higher number like 5 or 10 will cause your Flow to complete sooner.

Output Fields

  • list: The output list that contains the items, sorted from smallest to largest using the values returned for each item by the provided child Flow. The type of output list should be set to match the type of the input list (e.g. list of text).

Example

  • You have a list of text, e.g. ["this","is","a","sample"]

  • You create a child Flow that accepts a text input and returns the length of the text

  • Using Sort Custom, provide the list input and choose the child Flow above. For the input to the child Flow, click and choose "Item" from the dropdown

  • The output list of the Sort will be: ["a","is","this","sample"] - sorted from shortest to longest

See Also

About lists

Functions

About the elements of Okta Workflows