some sorting in generated code