     ORDER BY
       c.conrelid,
       m.m_table,
-      n.ref_depth NULLS FIRST,
+      n.ref_depth DESC,
       m.m_table_count DESC
   )
   LOOP

    ORDER BY
      c.conrelid,
      m.m_table,
      n.ref_depth NULLS FIRST,
      m.m_table_count DESC
  )
  LOOP

    AND a.attnotnull = FALSE;

  IF self_block IS NOT NULL THEN
    -- create a array delete function
    PERFORM citydb_pkg.create_array_delete_function($1, $2, $3);
  END IF;

