# Sort

> Drag each item into the group it belongs to.

```json
{
  "id": "p3",
  "prompt": "For a “saved searches” feature, sort each item.",
  "explanation": "Goals are measurable outcomes. Sharing and a redesign may be good ideas, but they're out of scope for this version.",
  "type": "sort",
  "groups": [
    {
      "id": "goal",
      "label": "Goal"
    },
    {
      "id": "non",
      "label": "Non-goal"
    }
  ],
  "items": [
    {
      "id": "a",
      "text": "Cut the time to rerun a search by 50%",
      "group": "goal"
    },
    {
      "id": "b",
      "text": "Share saved searches with teammates",
      "group": "non"
    },
    {
      "id": "c",
      "text": "Increase weekly searches per user by 10%",
      "group": "goal"
    },
    {
      "id": "d",
      "text": "Redesign the whole search page",
      "group": "non"
    }
  ]
}
```

A sort brick has two or more labelled groups and four to eight items. Drag each item into its group, or use the keyboard.

## When to use it

* Telling categories apart: goal or non-goal, `map` or `forEach`, formal or informal.

## Fields

| Field    | Required | Description                                               |
| -------- | -------- | --------------------------------------------------------- |
| `groups` | yes      | Each with an `id` and a `label`                           |
| `items`  | yes      | 4–8 items, each with `text` and the `group` it belongs to |

## More examples

```json
{
  "id": "p3",
  "prompt": "Which method fits each task?",
  "explanation": "If you need the results as a new array, use map. If you're just doing something for each item, use forEach.",
  "type": "sort",
  "groups": [
    {
      "id": "map",
      "label": "map"
    },
    {
      "id": "each",
      "label": "forEach"
    }
  ],
  "items": [
    {
      "id": "a",
      "text": "Turn prices into formatted strings",
      "group": "map"
    },
    {
      "id": "b",
      "text": "Log each error to the console",
      "group": "each"
    },
    {
      "id": "c",
      "text": "Get the length of every word",
      "group": "map"
    },
    {
      "id": "d",
      "text": "Send an email to each user",
      "group": "each"
    }
  ]
}
```
