Sort List
Last updated 3 weeks ago
The Sort List workflow action takes a delimited list stored in a property value, sorts the items alphabetically, and returns the cleaned result. Use it to normalize multi-value fields across your CRM so data is consistent and easy to compare.
How It Works
Add the Sort List action to any contact, company, deal, or ticket workflow in HubSpot. When a record reaches this step, the app reads the property you selected, splits it by your chosen delimiter, applies your sorting and cleanup options, and returns the sorted list along with summary information.
Action Inputs
When you add the Sort List action to a workflow, you'll configure the following fields:
| Field | Required | Description |
|---|---|---|
| Input List | Yes | The delimited list to sort |
| Delimiter | No | The delimiter used to separate list items (Comma, Semicolon, Pipe, Newline, or Space) |
| Sort Direction | No | Direction to sort the list (Ascending A-Z or Descending Z-A) |
| Remove Duplicates | No | Remove duplicate entries from the list |
| Trim Whitespace | No | Remove leading and trailing whitespace from each item |
Field Details
Delimiter Options:
| Option | Character | Best for |
|---|---|---|
| Comma (,) | , |
Tag lists, CSV-style values |
| Semicolon (;) | ; |
Multi-select fields, European-formatted data |
| Pipe (|) | | |
Pipeline-separated values |
| Newline | Line break | Multi-line text fields |
| Space | Single space | Space-separated words |
Sort Direction:
- Ascending (A-Z) - alphabetical order (default)
- Descending (Z-A) - reverse alphabetical order
Sorting is case-insensitive and uses natural ordering, so numbered items sort intuitively (e.g. item2 comes before item10).
Action Outputs
After the Sort List action runs, the following output values are available for use in subsequent workflow steps:
| Output | Type | Description |
|---|---|---|
| Sorted List | Text | The fully processed list, rejoined using the same delimiter |
| Item Count | Number | The number of items in the final sorted list (after removing empties and duplicates, if enabled) |
| Duplicates Removed | Number | The number of duplicate entries that were removed |
| Success | Yes/No | Whether the sorting operation completed without errors |
| Error Message | Text | If the operation failed, this contains a description of what went wrong |
Tip: To learn how to use these output values in later workflow actions (e.g., copy to a property, use in branching logic), see Using workflow action outputs in the HubSpot Knowledge Base.
Usage Examples
Normalizing a Tag List
A contact has a "Tags" property containing "sales, marketing, sales, support". You want to clean it up.
- Input List: Tags property
- Delimiter: Comma
- Sort Direction: Ascending (A-Z)
- Remove Duplicates: Checked
- Trim Whitespace: Checked
Result: "marketing, sales, support" -- sorted alphabetically with the duplicate "sales" removed.
Sorting Product Categories on a Deal
A deal has a "Product Categories" property containing "Enterprise;Starter;Professional". You want consistent ordering.
- Input List: Product Categories property
- Delimiter: Semicolon
- Sort Direction: Ascending (A-Z)
- Remove Duplicates: Unchecked
- Trim Whitespace: Checked
Result: "Enterprise;Professional;Starter".
Cleaning Up a Skills Field
A contact has a "Skills" property containing "Python, , JavaScript, python, CSS, JavaScript" (note the empty entry and case-variant duplicate).
- Input List: Skills property
- Delimiter: Comma
- Sort Direction: Ascending (A-Z)
- Remove Duplicates: Checked
- Trim Whitespace: Checked
Result: "CSS, JavaScript, Python" -- empty entries stripped, duplicates removed, and items sorted.
Tips
- Write the result back to a property. After sorting, use a subsequent workflow action to copy the Sorted List result back into the original property (or a separate "cleaned" property) so your CRM data stays normalized.
- Combine with enrollment triggers. Set your workflow to trigger whenever a specific property changes, so lists are automatically sorted every time they are updated.
- Use Item Count for validation. Branch on the item count to catch records with too few or too many values -- for example, flag contacts who have more than 10 tags for review.
- Check for duplicates proactively. Enable Remove Duplicates and branch on the Duplicates Removed result. If duplicates were found, you could log it, notify a team member, or trigger a data quality review.
- Empty lists are handled gracefully. If the input property is empty, the action succeeds with an empty result and an item count of zero. No errors are thrown.
Thank you for your feedback!
Your input helps us improve our documentation.