TRUECALC
MCP

data:sortRange

Sorts the range.

Parameters

NameTypeRequiredDescription
sheetstringyes
range{ from: string; to: string }yesThe rectangle to permute. Nothing outside it is read or written.
sortColumnstringyesThe column whose values order the rows, as an A1 column letter, "A", "AB". Must lie inside range.
direction"asc", "desc"yesSort order for sortColumn's values.

Returns

NameTypeRequiredDescription
range{ from: string; to: string }yesThe normalized rectangle actually sorted.
sortColumnstringyesThe sort column, canonical uppercase.
direction"asc", "desc"yesSort order for sortColumn's values.

Schema

Request payload, as JSON Schema:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Payload",
  "type": "object",
  "properties": {
    "sheet": {
      "type": "string"
    },
    "range": {
      "description": "The rectangle to permute. Nothing outside it is read or written.",
      "$ref": "#/$defs/CellRange"
    },
    "sortColumn": {
      "description": "The column whose values order the rows, as an A1 column letter, `\"A\"`, `\"AB\"`. Must lie inside `range`.",
      "type": "string"
    },
    "direction": {
      "$ref": "#/$defs/SortDirection"
    }
  },
  "required": [
    "sheet",
    "range",
    "sortColumn",
    "direction"
  ],
  "$defs": {
    "CellRange": {
      "description": "An inclusive rectangle. `from`/`to` may be equal, a single cell.",
      "type": "object",
      "properties": {
        "from": {
          "description": "Top-left cell, e.g. `\"A1\"`.",
          "type": "string"
        },
        "to": {
          "description": "Bottom-right cell, e.g. `\"B3\"`.",
          "type": "string"
        }
      },
      "required": [
        "from",
        "to"
      ]
    },
    "SortDirection": {
      "description": "Sort order for `sortColumn`'s values.",
      "type": "string",
      "enum": [
        "asc",
        "desc"
      ]
    }
  }
}

Response payload, as JSON Schema:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Output",
  "type": "object",
  "properties": {
    "range": {
      "description": "The normalized rectangle actually sorted.",
      "$ref": "#/$defs/CellRange"
    },
    "sortColumn": {
      "description": "The sort column, canonical uppercase.",
      "type": "string"
    },
    "direction": {
      "$ref": "#/$defs/SortDirection"
    }
  },
  "required": [
    "range",
    "sortColumn",
    "direction"
  ],
  "$defs": {
    "CellRange": {
      "description": "An inclusive rectangle. `from`/`to` may be equal, a single cell.",
      "type": "object",
      "properties": {
        "from": {
          "description": "Top-left cell, e.g. `\"A1\"`.",
          "type": "string"
        },
        "to": {
          "description": "Bottom-right cell, e.g. `\"B3\"`.",
          "type": "string"
        }
      },
      "required": [
        "from",
        "to"
      ]
    },
    "SortDirection": {
      "description": "Sort order for `sortColumn`'s values.",
      "type": "string",
      "enum": [
        "asc",
        "desc"
      ]
    }
  }
}

On this page