Category order is exposed on each category object as category_data.parent_category.ordinal. Pull the menu categories with SearchCatalogObjects (object_types: ["CATEGORY"]), keep the ones with category_type: MENU_CATEGORY, group them by parent_category.id (top-level categories have is_top_level: true and no parent id, but they still have an ordinal), then sort each group by parent_category.ordinal ascending.
Ordinals are 64-bit integers that can be large, negative, and non-contiguous, so sort by value instead of treating them as 0, 1, 2. Item order inside a category is separate and lives on the item, in item_data.categories[].ordinal. See CatalogCategory and CatalogObjectCategory.