Skeleton for topological sort
diff --git a/gen/src/write.rs b/gen/src/write.rs
index 2967594..1cd6d07 100644
--- a/gen/src/write.rs
+++ b/gen/src/write.rs
@@ -1,7 +1,7 @@
 use crate::gen::block::Block;
 use crate::gen::nested::NamespaceEntries;
 use crate::gen::out::OutFile;
-use crate::gen::{builtin, include, Opt};
+use crate::gen::{builtin, include, toposort, Opt};
 use crate::syntax::atom::Atom::{self, *};
 use crate::syntax::symbol::Symbol;
 use crate::syntax::{
@@ -76,7 +76,7 @@
         }
     }
 
-    for api in apis {
+    for api in toposort::sort(apis, out.types) {
         match api {
             Api::Struct(strct) => {
                 out.next_section();