diff --git a/src/components/gui/schema-sidebar-list.tsx b/src/components/gui/schema-sidebar-list.tsx index e44039b..fb403c6 100644 --- a/src/components/gui/schema-sidebar-list.tsx +++ b/src/components/gui/schema-sidebar-list.tsx @@ -89,6 +89,10 @@ function groupByFtsTable(items: ListViewItem[]) { return items.filter((item) => !excludes.has(item.data.name)); } +function sortTable(items: ListViewItem[]) { + return items.sort((a, b) => a.name.localeCompare(b.name)); +} + function flattenSchemaGroup( schemaGroup: ListViewItem[] ): ListViewItem[] { @@ -154,17 +158,19 @@ export default function SchemaList({ search }: Readonly) { ); const listViewItems = useMemo(() => { - const r = Object.entries(schema).map(([s, tables]) => { - return { - data: { type: "schema", schemaName: s }, - icon: LucideDatabase, - name: s, - key: s.toString(), - children: groupByFtsTable( - groupTriggerByTable(prepareListViewItem(tables)) - ), - } as ListViewItem; - }); + const r = sortTable( + Object.entries(schema).map(([s, tables]) => { + return { + data: { type: "schema", schemaName: s }, + icon: LucideDatabase, + name: s, + key: s.toString(), + children: sortTable( + groupByFtsTable(groupTriggerByTable(prepareListViewItem(tables))) + ), + } as ListViewItem; + }) + ); if (databaseDriver.getFlags().optionalSchema) { // For SQLite, the default schema is main and