sorting

A guide to ordering table rows with ascending, descending, multi-column, and undefined-value rules. It covers both sorting rows in the browser and displaying an order supplied by a server.

In plain words
What is it for?
Use it when adding sortable headers, multi-column sorting, custom comparison rules, or requests that send sorting choices to an API.
Why use it?
It prevents the table from showing a sorting control without actually changing the data, especially when server-side sorting is enabled. It also makes sorting cycles and missing-value placement explicit.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/tanstack/table/sorting
Any agent
npx skills add TanStack/table --skill sorting
Clone the repo
git clone --depth 1 https://github.com/TanStack/table

Made for: Claude Code, Codex.

Per session 43 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 719 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00043 $0.00719
Opus 5 $0.00022 $0.00360
Sonnet 5 $0.00009 $0.00144
Haiku 4.5 $0.00004 $0.00072

Measured 2d ago against content hash 9d49320e546a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

sorting scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

packages/table-core/skills/sorting/SKILL.md · 83 lines

How it starts

The opening of the file, as written. The whole thing — 83 lines — stays where its author put it; the contents beside it link to each section on GitHub.

This skill builds on core, table-features, and client-vs-server. Sorting state describes order; client processing requires a sorted model and server processing requires sorted input.

Setup

import {
  createSortedRowModel,
  rowSortingFeature,
  sortFn_alphanumeric,
  sortFn_text,
  tableFeatures,
} from '@tanstack/table-core'

export const features = tableFeatures({
  rowSortingFeature,
  sortedRowModel: createSortedRowModel(),
  sortFns: { alphanumeric: sortFn_alphanumeric, text: sortFn_text },
})

Import individual sortFn_* built-ins and register only those your columns reference by string name or that sortFn: 'auto' should resolve for your data types. The full sortFns registry object still works but bundles every built-in; numeric columns fall back to a basic comparator without registration.

Core Patterns

const options = { enableSortingRemoval: false, enableMultiSort: true }
const numericColumn = { sortUndefined: 'last' as const }

Configure sort cycles and undefined placement to match the product rather than relying on implicit defaults.

Common Mistakes

[CRITICAL] Expecting manual mode to reorder

Wrong: const options = { data: unsortedRows, manualSorting: true }

Correct: const options = { data: serverSortedRows, manualSorting: true }

Manual sorting bypasses sortedRowModel and trusts incoming order.

Source: packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts

[HIGH] Reversing inside the comparator

Wrong: const newest: SortFn<any, any> = (a, b, id) => b.getValue<number>(id) - a.getValue<number>(id)

Correct: const numeric: SortFn<any, any> = (a, b, id) => a.getValue<number>(id) - b.getValue<number>(id)

Return ascending comparison only; Table reverses it when sorting is descending.

Source: docs/framework/react/guide/sorting.md#custom-sorting-functions

[MEDIUM] Leaving ambiguous sort policy

Wrong: const options = { enableSortingRemoval: true }

Correct: const options = { enableSortingRemoval: false }; const rankColumn = { sortUndefined: 'last' as const }

Read the full file on GitHub · 83 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 83 lines · 43 tokens per session scan A 9d49320e546a

Subscribe to this mod's changes

sorting is a skill published in the GitHub repository TanStack/table (28,393 stars, last pushed 2d ago), licensed MIT. It adds 43 tokens to every session and 719 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

gsap-performance

Official GSAP skill for performance — prefer transforms, avoid layout thrashing, will-change, batching. Use when optimizing GSAP animations, reducing jank, or when the user asks about animation performance, FPS, or smooth 60fps.

12-Studio/Tackl · 52 tokens

next-cache-components-adoption

Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…

vercel/next.js · 95 tokens

next-rspack

Maintain @next/rspack-core and @next/rspack-binding packages. Use when editing rspack/package.json, rspack/crates/binding/Cargo.toml, rspack/rust-toolchain.toml, or packages/next-rspack/package.json. Covers upgrading @rspack/core npm version, rspack crate versions, Rust toolchain version, building and linking for…

vercel/next.js · 113 tokens

next-dev-loop

Verify Next.js runtime behavior after editing app code. Use this skill to confirm a change actually works in a running app — not just that it compiles or type-checks. Combines /next/mcp (Next.js's view) with agent-browser (the browser's view). Requires a running next dev.

vercel/next.js · 68 tokens

flow

Use when you need to run Flow type checking, or when seeing Flow type errors in React code.

react/react · 22 tokens

react-grab

Use when the user wants a hands-free loop where grabbing UI elements in the browser with React Grab feeds tasks to the agent automatically, with no copy-paste or manual handoff. Triggers: "watch react grab", "monitor my grabs", "auto-process react grab", "watch my clipboard for grabs". Not for a one-off paste of a…

aidenybai/react-grab · 86 tokens