                   cols.item_group_id
                 ORDER BY
                   cols.item_ordinal_per_ig_over_crfv,
-                  cols.item_multi_order_over_rsi),
+                  cols.item_multi_order_over_rsi NULLS FIRST,
+                  cols.column_sequence),
               0,
               200000,
               1000) AS item_group_bucket,

          ddl.study_name_clean,
          ddl.item_group_id,
          ddl.item_ordinal_per_ig_over_crfv,
          ddl.item_multi_order_over_rsi NULLS FIRST), chr(44)),
      (SELECT group_footer
       FROM format_strings)
    ) AS create_statement,

              item_group_oid,
              item_group_repeat,
              jsonb_object_agg(av_ident_final, data_text)
                FILTER (WHERE cast_failure) AS cast_failures,
            %5$s %6$s $f$ :: TEXT AS group_header,
      $f$ FROM study_ig_clinicaldata
          GROUP BY
