How to Run Interval Comparison in Shortcuts

It’s the allergy season of the year. My favorite weather apps are yet to cover South Korea’s allergy-related forecast, so I end up pulling present data from local sources. That being said, the number I get is not put into the useful context; I want to know if it’s low, moderate, or high, not the actual pollen count.

Let’s assume you have a number M. You want to compare it to the array of the numbers (e.g. n1, n2, n3 …) to see if it’s within certain range. This custom shortcut returns just that; where the number M would be in, if it were to be inserted into the array.

  1. Download the shortcut from this link.
  2. In order to use the shortcut, a dictionary must be passed in text format:
{"input": M, "array": [n1, n2, n3, ...]}

For example, this would return 2 as the result:

{"input": 10, "array": [5, 15, 25]}

Please be mindful that the array must be ordered. To properly use the shortcut, it’s best to run it from another shortcut and process the result as needed.

As always, you can create your own version of the shortcut. It’s simply repeating through each item in the array until the input M is less than or equal to the repeated item’s index number. Shortcuts app will ask if you do wish to let a shortcut run another shortcut when run for the first time.

Leave a comment