# Integer sort

`integer-sort` · version 1.0.0 · Numbers & math · free, no key needed

Stable-sort canonical signed base-10 integer strings using BigInt.

**Use when you need to: integer sort · sort integer strings · order integers.**

## Supported

- integer sort
- sort integer strings
- order integers

## Not supported

- locale sort
- floats
- natural sort of mixed tokens

## Behavior

- Inputs are canonical signed base-10 integer strings matching /^-?(0|[1-9][0-9]*)$/.
- Leading zeros, plus signs, spaces, decimals, exponents, hex, empty strings, and -0 are rejected.
- At most 256 digits excluding the sign. Computation uses BigInt. JSON BigInt is never returned.
- Canonical form is unchanged; 0 is "0". Returned strings are the original canonical inputs.
- values is an array of canonical integer strings with at most 10000 items.
- order is "asc" (default) or "desc". Unknown order values are rejected.
- Equal values keep their original order (stable sort).

## Input

- `values` (array of string, required): max items 10000
- `order` (one of "asc", "desc", optional)

## Output

- `values` (array of string, required)

## Limits

- max integer digits: 256
- max items: 10000

## Example

Request input:

```json
{
  "values": [
    "10",
    "-2",
    "10",
    "0"
  ]
}
```

Response:

```json
{
  "result": {
    "values": [
      "-2",
      "0",
      "10",
      "10"
    ]
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "integer-sort",
  "version": "1.0.0",
  "input": {
    "values": [
      "10",
      "-2",
      "10",
      "0"
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/integer-sort/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"values":["10","-2","10","0"]}'
```

The machine-readable contract is at [/v1/tools/integer-sort/versions/1.0.0](/v1/tools/integer-sort/versions/1.0.0).

### CLI

```sh
node cli.mjs run integer-sort 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Array integer mode](/tools/array-integer-mode): Return the most frequent canonical integers, listing every mode in first-seen order.
- [Integer add](/tools/integer-add): Add two canonical signed integer strings and return their canonical sum.
- [Integer compare](/tools/integer-compare): Compare two canonical signed base-10 integer strings using BigInt.
- [Array integer cumulative sum](/tools/array-integer-cumulative-sum): Replace an array of canonical integer strings with equal-length prefix sums.
- [Array integer GCD](/tools/array-integer-gcd): Compute the non-negative greatest common divisor of an array of canonical integer strings.
- [Array integer LCM](/tools/array-integer-lcm): Compute the non-negative least common multiple of an array of canonical integer strings.
