一键导入
table-sort-defaults
Default sort order by column type for sortable tables; use when adding or changing sortable tables or backend list endpoints.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Default sort order by column type for sortable tables; use when adding or changing sortable tables or backend list endpoints.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | table-sort-defaults |
| description | Default sort order by column type for sortable tables; use when adding or changing sortable tables or backend list endpoints. |
Use this skill when adding or changing sortable tables (ResourceTableWithFilter, TableWithFilter, TableWithSort) or backend list endpoints that accept sortBy/sortOrder. Keeps sort indicators and data order consistent with user expectations. For ensuring any table that displays list data supports sorting, see tables-support-sorting (.cursor/skills/tables-support-sorting/SKILL.md). For persisting sort in a cookie by path (e.g. bucket-detail messages/buckets), see sort-prefs-cookie-by-path (.cursor/skills/sort-prefs-cookie-by-path/SKILL.md).
This file is the authority for default sort-order rules by column type.
| Column type | Default order | Rationale |
|---|---|---|
| String | asc (A→Z) | Alphabetical is the natural reading order. |
| Number | asc (smallest first) | Ascending is conventional unless "latest" is the goal. |
| Date | desc (newest first) | Lists (events, admins by created) typically show newest first. |
The header icon reflects the current sort: up = ascending, down = descending. So string columns should default to asc and show an up arrow on first load.
packages/ui) supports optional defaultSortOrder?: 'asc' | 'desc'.sortBy/sortOrder in the URL (first sortable column’s default).effectiveSortOrder when the URL has no sortOrder (active column’s default).defaultSortOrder, legacy behavior is used (default 'desc').When adding or changing a sortable table, set defaultSortOrder on each column:
defaultSortOrder: 'asc'.defaultSortOrder: 'desc'.defaultSortOrder: 'asc'.Example (buckets list, string columns):
const columns = [
{ id: 'name', label: t('name'), defaultSortOrder: 'asc' as const },
{ id: 'isPublic', label: t('isPublic'), defaultSortOrder: 'asc' as const },
];
Example (events, timestamp first):
const eventColumns = [
{ id: 'timestamp', label: tCommon('eventsTable.timestamp'), defaultSortOrder: 'desc' as const },
{ id: 'actor', label: tCommon('eventsTable.actor'), defaultSortOrder: 'asc' as const },
// ...
];
When the API receives sortBy but no sortOrder, default according to the sort field:
createdAt, timestamp): default DESC.Examples:
packages/orm BucketService: orderDir = orderBy === 'createdAt' ? 'DESC' : 'ASC' when sortOrder is undefined.packages/management-orm ManagementUserService: same for admins list.sortOrder is missing, use ASC for string fields and DESC for date fields (e.g. sortBy === 'createdAt' ? 'DESC' : 'ASC').This keeps direct API calls and any URL without sortOrder aligned with the same UX.
packages/ui/src/components/table/TableFilterBar/TableFilterBar.tsx — TableFilterBarColumn.defaultSortOrder.packages/ui/src/components/table/ResourceTableWithFilter/ResourceTableWithFilter.tsx, packages/ui/src/components/table/TableWithFilter/TableWithFilter.tsx — initial effect and effectiveSortOrder fallback.apps/web/.../buckets/page.tsx, apps/management-web/.../admins/page.tsx, users/page.tsx, buckets/page.tsx, events/page.tsx).packages/orm/src/services/BucketService.ts, packages/management-orm/src/services/ManagementUserService.ts, apps/management-api/src/controllers/usersController.ts (and any other list endpoint that accepts sortBy/sortOrder).When changing API routes, auth, or env-dependent behavior, add or update the corresponding integration tests and keep the test file layout consistent.
When adding or changing files under infra/k8s/ or sync targets for k8s, know what Argo CD syncs and remind the user to push to Git so the cluster can sync.
Keeps tools/generate-data seeders and docs in sync when main or management DB schema or ORM entities change. Use when adding or changing tables/entities in packages/orm, packages/management-orm, or infra database migrations.
When changing DB schema or permission dimensions, consider predefined roles and bucket_role / role-related code.
Use when adding or changing environment variables, infra/env/classification YAML, scripts/env-classification, K8s env render, or local env generation.
Common patterns for the Boilerplate HTTP API (Express)