Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql	29 Mar 2001 05:38:45 -0000	1.5
+++ openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql	30 Mar 2001 03:03:08 -0000	1.6
@@ -406,6 +406,7 @@
                  i2.tree_sortkey <= i1.tree_sortkey
                and
                  i1.tree_sortkey like (i2.tree_sortkey || ''%'')
+               order by i2.tree_sortkey desc
   LOOP
     v_parent_id := v_rec.parent_id;
     exit when v_parent_id = is_sub_folder__folder_id;
@@ -575,18 +576,30 @@
       content_type = is_registered__content_type;
 
   else
+--                         select
+--                            object_type
+--                          from 
+--                            acs_object_types
+--                          where 
+--                            object_type <> ''acs_object''
+--                          connect by 
+--                            prior object_type = supertype
+--                          start with 
+--                            object_type = is_registered.content_type 
 
     v_is_registered := 1;
     for v_subtype_val in select 
                            object_type
                          from 
                            acs_object_types
                          where 
-                           object_type <> 'acs_object'
-                         connect by 
-                           prior object_type = supertype
-                         start with 
-                           object_type = is_registered.content_type 
+                           object_type <> ''acs_object''
+                         and 
+                           tree_sortkey 
+                             like (select tree_sortkey || ''%''
+                                     from acs_object_types
+                                    where object_type = is_registered__content_type)
+                         order by tree_sortkey
     LOOP
       if content_folder__is_registered(is_registered__folder_id,
                        v_subtype_val.object_type, ''f'') = ''f'' then
