How to sort a list of duplicate text items

I have a list of text fields containing some duplicates, and I would like to show it in a repeating group with the count of duplicates next to each text field, and then sort it in a descending order of the number of duplicates for each item

For instance:
California
California
Hawaii
California
New York
New York
New York
California

Should become:
California 4
New York 3
Hawaii 1

I was able to display the list in a repeating group by showing the unique items, and the count for each, but I am not able to sort the repeating group by the number of duplicates for each item as it is calculated in real time.

I don’t want to create a new data type for the {State, Count} pair and populate it with that list.

Is there any other way to do it?

Thanks in advance!

You’ll need to calculate the frequency of the items in a separate action. If this list is constantly changing, I would store the list in a custom state (if more static, maybe save to a data type) and then set the repeating group list to that custom state.
When you set the custom state however, you’ll want to “:append” the count to the start of the state name then in the repeating group, split out the items using “extract with regex”

Someone may have a more clever approach but that’s the way I would tackle it.

This topic was automatically closed after 70 days. New replies are no longer allowed.