25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
export type StructureIndexColumnSort = "asc" | "desc";
/**
* Sorts index drafts by their key-column list (#12550). The joined column list
* keeps composite indexes grouped by their leading column; the primary key
* always stays first because it is the table identity, not a maintenance index.
*/
export function sortStructureIndexesByColumns<T extends { columns: readonly string[]; isPrimary: boolean }>(indexes: readonly T[], direction: StructureIndexColumnSort): T[] {
const factor = direction === "asc" ? 1 : -1;
const sorted = [...indexes].sort((left, right) => {
const leftKey = left.columns.join("\u0000").toLowerCase();
const rightKey = right.columns.join("\u0000").toLowerCase();
return leftKey.localeCompare(rightKey) * factor;
});
return [...sorted.filter((index) => index.isPrimary), ...sorted.filter((index) => !index.isPrimary)];
}