How to filter and sort lists

Objective:

Learn how to use the Filter and Sort blocks

Procedure:

In many cases, it may be useful to make changes to listed blocks in order to rearrange the order of lists, through sorting, and remove certain items from a list, through filtering (see the ‘Sorted #’s low-high variable in the file).

 

Sort

The Sort block will rearrange a list from the lowest to the highest value. If you would like the values sorted from highest to lowest, you can use the ‘reversed’ scalar list in the block’s properties (see the ‘Sorted #’s high-low’ variable in the attached file).

sort_high_low_reverse.gif

 

Filter

The Filter block removes items from a list based on a Bool List, which must be the same length as the List input in the block. The default state of the Filter block takes in a Bool list, which is a series of checkboxes, where items in the list can be kept or removed from the input lists by toggling the checkboxes (see the ‘Filtered spheres’ variable in the attached file).

filter_bool.gif

The Filter block allows a list to be filtered by a scalar list of the same length, by selecting the second option in the dropdown menu from the arrow next to the block’s name (see the ‘Filtered spheres by #’s’ variable in the attached file).

Filter_Overload.gif

Filtering is useful for many different application areas, especially when you want to add more intelligence to your workflows and isolate or add conditionals for certain types of results. This naturally makes filtering useful for Simulation workflows, where a lot of data is generated. An example of filtering in Simulation workflows is: Looking at Min values and looking at Max values. 

Download the Example file:

More on this topic:

Keywords:

 blocks list how to filter scalar sort process bool filtering sorting 
Was this article helpful?