{
  "slug": "sort-json-array",
  "name": "gizza-ai/sort-json-array",
  "version": "0.1.0",
  "title": "Sort JSON Array — Order Objects by Field — gizza.ai",
  "description": "Sort a JSON array of objects by one or more fields, ascending or descending. Supports nested dot-paths, per-key direction, missing-value placement, and minify.",
  "tags": [
    "sort json array",
    "sort json by key",
    "order json objects",
    "json array sorter",
    "sort json by field",
    "json order by"
  ],
  "category": "data",
  "urls": {
    "page": "https://gizza.ai/tools/sort-json-array/",
    "markdown": "https://gizza.ai/tools/sort-json-array/index.md",
    "descriptor": "https://gizza.ai/tools/sort-json-array/tool.json",
    "deep_link_example": "https://gizza.ai/tools/sort-json-array/?json=%5B%20%7B%20%22name%22%3A%20%22Ada%22%2C%20%22age%22%3A%2036%20%7D%2C%20%7B%20%22name%22%3A%20%22Bo%22%2C%20%22age%22%3A%2024%20%7D%20%5D&keys=dept%2C-salary%2Cname&order=asc&missing=last&case_insensitive=true&indent=2"
  },
  "cli": "gizza tool sort-json-array '[ { \"name\": \"Ada\", \"age\": 36 }, { \"name\": \"Bo\", \"age\": 24 } ]' 'keys=dept,-salary,name'",
  "tool": {
    "description": "Sort a JSON array of objects by the value of one or more fields (the ORDER BY / _.orderBy operation), validating the input first. keys is a comma-separated list of fields; use dot-notation for nested paths ('address.city') or an array index ('tags.0'), and prefix a key with '-' (descending) or '+' (ascending) to override the per-key direction, e.g. 'dept,-salary,name'. order is the default direction 'asc' (default) or 'desc'; missing places rows whose field is absent or null 'last' (default) or 'first'; set case_insensitive=true to compare strings ignoring case (numbers always compare numerically); indent is spaces per level (1-8, default 2), or 0 to minify. This sorts array ELEMENTS by a field — to alphabetize object KEYS use json-sort instead. Runs locally.",
    "parameters": {
      "additionalProperties": false,
      "properties": {
        "case_insensitive": {
          "default": false,
          "description": "Compare string values ignoring case so 'Banana' sorts next to 'apple'. Off by default, where uppercase letters sort before lowercase (codepoint order). Numbers always compare numerically.",
          "type": "boolean"
        },
        "indent": {
          "default": 2,
          "description": "Spaces of indentation per level (1-8) in the output. Use 0 to minify to a single compact line. Default 2.",
          "maximum": 8,
          "minimum": 0,
          "type": "integer"
        },
        "json": {
          "description": "The JSON text — a top-level array of objects — to sort by field value.",
          "type": "string"
        },
        "keys": {
          "description": "Comma-separated field(s) to sort by. Use dot-notation for nested paths ('address.city') or an array index ('tags.0'). Prefix a key with '-' for descending or '+' for ascending to override 'order' per key, e.g. 'dept,-salary,name'.",
          "type": "string"
        },
        "missing": {
          "default": "last",
          "description": "Where rows whose sort field is absent or JSON null go: 'last' (default) or 'first'. Placement is absolute — it does not flip with descending order.",
          "enum": [
            "last",
            "first"
          ],
          "type": "string"
        },
        "order": {
          "default": "asc",
          "description": "Default direction for keys with no +/- prefix: 'asc' (smallest first, default) or 'desc' (largest first).",
          "enum": [
            "asc",
            "desc"
          ],
          "type": "string"
        }
      },
      "required": [
        "json",
        "keys"
      ],
      "type": "object"
    }
  }
}