Search HoldMyTwist

Sort tasks by numeric priority in Make

Sort three tasks by numeric priority in Make Free. Check the field type, preserve each task record, and see why quoted numbers change the order.

A brass sorting arm arranging navy blocks from shortest to tallest on aqua steps

Text values can put 10 before 2 when you expected numerical order. This Make Free exercise sorts three fictional task records by a numeric priority field, keeping each task with its priority.

Before you start

You can create a Make Free account (opens in a new tab) or sign in. No other app connection is needed. Keep the scenario Inactive and use Run once.

1. Create three task records

  1. In Scenarios, click Create scenario. Name it Numeric priority practice at the top left.
  2. Add JSON > Parse JSON. Leave Data structure empty and paste the sample below into JSON string.
  3. Save the module and scenario. Choose Save anyway only for an unused-output warning.
  4. Click Run once, then Run anyway for that warning. Inspect the source output before mapping it.
Text to copy

{"jobs":[{"task":"Write","priority":10},{"task":"Fix","priority":2},{"task":"Review","priority":1}]}

Full Make editor showing task records with unquoted numeric priorities 10, 2 and 1

Full Make editor showing task records with unquoted numeric priorities 10, 2 and 1
Open full-size image

Keep 10, 2 and 1 unquoted. In this example, a smaller number means a higher priority. Choose an order that matches your own priority system.

2. Sort the array by its priority field

  1. Close the result panel. Click the plus to the right of JSON and choose Tools > Set variable.
  2. Set Variable name to sorted_jobs.
  3. Paste the expression below into Variable value. Check that jobs is a coloured token from JSON module 1. If your JSON module has another number, select its jobs array from the mapping panel.
  4. Save the module and scenario.
Text to copy

{{sort(1.jobs; "asc"; "priority")}}

Sort the whole records by their priority property.

Full Make editor applying sort to jobs in ascending order using priority

Full Make editor applying sort to jobs in ascending order using priority

Sort the whole records by their priority property.

Open full-size image

Watch out

The field type changes the order. With numeric priorities, this example returns 1, 2, 10. When the same values are quoted as text, it returns 1, 10, 2. Correct the source type before trusting the sorted list.

3. Check every sorted record

  1. Click Run once.
  2. Open the Tools result bubble. Under Output, expand sorted_jobs, then expand all three items.
  3. Check the order: Review, 1; Fix, 2; Write, 10.

Full Make editor showing Review priority 1, Fix priority 2 and Write priority 10

Full Make editor showing Review priority 1, Fix priority 2 and Write priority 10
Open full-size image

Each task stays attached to its priority. The result is a sorted array inside one output bundle.

If 10 appears before 2

Inspect the source's field type. In JSON, "10" is text and 10 is a number. If another app supplies numeric values as text, convert them before sorting and check known examples. Make documents parseNumber (opens in a new tab) for reading numeric text. To reverse this exercise's order, replace asc with desc and inspect the output again.

For a one-off sort, a spreadsheet may be simpler. Check the Free-plan limits before scheduling this in Make.

Sources: Make array functions (opens in a new tab); Make JSON documentation (opens in a new tab). Screenshots show fictional practice data.

Share this guide