Sort data
Sort the table's rows or a list variable, up or down.
In both apps
WarpX Browser
WarpX Phone
Sort data puts a list in order: the rows of the workflow's table, or a list held in a variable. Sort plain values as they are, or sort objects by their properties, such as columns. With more than one property, the first sets the order and the others break ties.
Settings
- Data source
Sort the workflow's table, or a list in a variable.
ExampleTable- Variable namewhen Data source is Variable
The variable to sort. It must hold a list.
Exampleprices- Sort by the item's property
Turn this on to sort objects, such as table rows, by a property. Off, the items are compared as they are, which suits a list of numbers or text.
ExampleChecked- Add propertywhen Sort by the item's property is on
Each row is a property name (a column name for the table) and Ascending or Descending. You can add up to three. The first row sets the order. Each row below it only orders the items the rows above left tied, in its own direction.
Examplerating | Descending reviews | Descending
- Assign to variable
Also store the sorted list in a variable.
ExampleUnchecked- Variable namewhen Assign to variable is ticked
The variable that receives the sorted list.
ExampletopProducts- Insert to table
Put the whole sorted list into one cell of the table.
ExampleUnchecked- Select columnwhen Insert to table is ticked
The column that receives the list.
Examplesorted
Every block also has the shared block settings — a description, Disable block and what to do on an error. Fields that take text accept data from earlier blocks.
What it hands on
The source is sorted where it is: the table's rows, or the variable's list, change order. The sorted list also goes on as {{prevBlockData}}, and to the variable or column you chose.
Example: Put the best rated products first, most reviewed first among equals
- Start
- Open URL
- Get text
- Sort data
- Google Sheets
- In the workflow's table, add columns
product,ratingandreviews, and set the Data type ofratingandreviewsto Number. - Fill them from the page with Get text and Insert to table.
- Add Sort data and keep Data source on Table.
- Turn on Sort by the item's property. Click Add property, type
ratingand choose Descending. - Click Add property again, type
reviewsand choose Descending. - Send the table on with Google Sheets. The highest rated products come first, and products with the same rating are ordered by their number of reviews.
Good to know
- When an item has no value for a property, the whole item is compared in its place, which gives no useful order. Make sure every row has a value in the columns you sort by.
- Text is compared as text, so
100comes before25. Give a column the Number data type when you want number order. - Sorting table rows with Sort by the item's property off leaves them as they were: rows are objects and do not compare.
- A source that is not a list stops the block, for example
Can't sort data with "string" data type.
See also
- Data mapping — Copy chosen properties of the table or a variable into new names.
- Loop data — Run the blocks after it once for each row, number, list item or element.
- Google Sheets — Read rows from a Google Sheet, keep only the ones you want, or write, append and clear cells.