Sort list
Function: Sort list
This action helps you organize any collection of items (a list) by arranging them based on a specific piece of information within each item, either from smallest to largest or largest to smallest. It's perfect for bringing order to your data.
Input,
- List to Sort: This is the collection of items you want to arrange. It could be a list of numbers, text, or more complex records like customer details or product information. This input is required.
- Sort by: This is where you define how the list should be organized. You can add one or more sorting rules.
- Attribute: Choose the specific piece of information within each item that you want to sort by. For example, if you have a list of products, you might choose "Price" or "Product Name".
- Order: Decide whether the list should be sorted in "Ascending" order (e.g., A-Z, 1-100, oldest to newest) or "Descending" order (e.g., Z-A, 100-1, newest to oldest).
Output,
- Result: This is the new, organized list that the action creates after applying your sorting rules. By default, it will be stored in a variable named "RESULT", but you can choose a different name.
Execution Flow,
Real-Life Examples,
Example 1: Organizing Product Prices
Imagine you have a list of products, and you want to see them ordered from the cheapest to the most expensive.
- Inputs:
- List to Sort:
[ \{ "Product": "Laptop", "Price": 1200 \}, \{ "Product": "Mouse", "Price": 25 \}, \{ "Product": "Keyboard", "Price": 75 \} ] - Sort by:
- Attribute:
Price - Order:
Ascending
- Attribute:
- List to Sort:
- Result: The
RESULTvariable will contain the list sorted by price from lowest to highest:[ \{ "Product": "Mouse", "Price": 25 \}, \{ "Product": "Keyboard", "Price": 75 \}, \{ "Product": "Laptop", "Price": 1200 \} ]
Example 2: Arranging Customer Names Alphabetically
You have a list of customer records and need to display them in reverse alphabetical order by their last name.
- Inputs:
- List to Sort:
[ \{ "FirstName": "Alice", "LastName": "Smith" \}, \{ "FirstName": "Bob", "LastName": "Johnson" \}, \{ "FirstName": "Charlie", "LastName": "Brown" \} ] - Sort by:
- Attribute:
LastName - Order:
Descending
- Attribute:
- List to Sort:
- Result: The
RESULTvariable will contain the list sorted by last name from Z to A:[ \{ "FirstName": "Alice", "LastName": "Smith" \}, \{ "FirstName": "Bob", "LastName": "Johnson" \}, \{ "FirstName": "Charlie", "LastName": "Brown" \} ]
Example 3: Ordering Tasks by Due Date
You're managing a project and have a list of tasks. You want to see the tasks ordered by their due date, with the earliest due dates appearing first.
- Inputs:
- List to Sort:
[ \{ "Task": "Review Report", "DueDate": "2023-11-15" \}, \{ "Task": "Send Invoice", "DueDate": "2023-11-10" \}, \{ "Task": "Schedule Meeting", "DueDate": "2023-11-20" \} ] - Sort by:
- Attribute:
DueDate - Order:
Ascending
- Attribute:
- List to Sort:
- Result: The
RESULTvariable will contain the list sorted by due date from earliest to latest:[ \{ "Task": "Send Invoice", "DueDate": "2023-11-10" \}, \{ "Task": "Review Report", "DueDate": "2023-11-15" \}, \{ "Task": "Schedule Meeting", "DueDate": "2023-11-20" \} ]