Group and Sort

Learn to use the group_by() and take_sort() functions in the Flow module.

We'll cover the following

Group

Like Enum.group_by/2, Flow.group_by/2 groups the data by the given criteria. They both are implemented using the reduce function behind the scenes. Therefore, we’ll keep our Flow.partition/2 function to continue routing events to the correct process. This ensures that the same process groups airports of the same country.

Let’s replace Flow.reduce/3 with Flow.group_by/2:

Get hands-on with 1200+ tech skills courses.