Index: src/hg/hgTables/hgTables.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTables/hgTables.c,v
retrieving revision 1.187
retrieving revision 1.188
diff -b -B -U 4 -r1.187 -r1.188
--- src/hg/hgTables/hgTables.c	12 Jun 2009 14:18:04 -0000	1.187
+++ src/hg/hgTables/hgTables.c	4 Jan 2010 19:12:22 -0000	1.188
@@ -904,13 +904,15 @@
             }
 	}
     if (tdbIsComposite(track))
         {
-        struct trackDb *subTdb;
         struct slName *subList = NULL;
-	slSort(&(track->subtracks), trackDbCmp);
-        for (subTdb = track->subtracks; subTdb != NULL; subTdb = subTdb->next)
+	struct slRef *tdbRefList = trackDbListGetRefsToDescendantLeaves(track->subtracks);
+	slSort(&tdbRefList, trackDbRefCmp);
+	struct slRef *tdbRef;
+	for (tdbRef = tdbRefList; tdbRef != NULL; tdbRef = tdbRef->next)
             {
+	    struct trackDb *subTdb = tdbRef->val;
 	    name = slNameNew(subTdb->tableName);
 	    slAddTail(&subList, name);
 	    hashAdd(uniqHash, subTdb->tableName, NULL);
             }

