Hmm, I’ve never found a built-in service to sort String lists.
I think what you’re telling me here is that problem does not play Flow’s strengths as much as I imagined it would - in as much as you have to write an algorithm (however simple) with temporary variables and so forth. It felt as if since Flow is good at mapping, it might also be good at folding too, and I’d missed a feature.
Just for reference the Java version is:
Set set = new TreeSet();
String filtered = set.toArray();
So I put that in a Java service and put it in my “things that should be BIS” package.
Here you create a temporary treeset instance, which is by definition sorted in ascending order, and you use a method which only adds if not already present. This is almost exactly what was suggested in the flow solution, which, frankly, would have been more readable.
I could equally have used a HashSet, which is not sorted. The important ‘by definition’ here is that as Set is “A collection that contains no duplicate elements.”
True, although it’s not important whether this method “only adds if not already present” or “always adds, replacing the previous instance”. The point is that any method that adds to a set will not result in a duplicate item.
I can’t – and I’ve tried – make this brief or readable in Flow. Here’s my best attempt: