fix C++ compilation warning
generate cdef classes and closure classes in a deterministic order to reduce C code churn on regeneration
also fixes a problem where duplicate entries (one used, one unused) could be selected somewhat arbitrarily during type sorting (apparently applied to but worked for memoryview/-slice)