I'm looking for a clever way to do the following operation:
Take a list of numbers:
1, 2, 3, 4, 5, 12, 13, 14, 19
and compact it into a string like so:
1-5, 12-14, 19
With the following rule: only compress into a range (i.e. use a dash) when the count of numbers in the range is 3 or more.
I.e.: 1, 2, 4, 5 would result in: 1, 2, 4, 5 and NOT: 1-2, 4-5