468608d7e217375418840f1f65ce90884b6c8962
tdreszer
  Fri Jan 14 16:00:44 2011 -0800
And a little more tweeking.  Don't create a default column when all values will be the same
diff --git src/hg/lib/fileUi.c src/hg/lib/fileUi.c
index cb5f0e9..6dc1561 100644
--- src/hg/lib/fileUi.c
+++ src/hg/lib/fileUi.c
@@ -165,46 +165,50 @@
 if (parentTdb)
     setting = trackDbSetting(parentTdb, FILE_SORT_ORDER);
 if(setting)
     {
     sortOrder = needMem(sizeof(sortOrder_t));
     sortOrder->setting = cloneString(setting);
     carveSetting = sortOrder->setting;
     }
 else
     {
     if (mdbObjs != NULL)
         {
         struct dyString *dySortFields = dyStringNew(512);
         struct mdbObj *commonVars = mdbObjsCommonVars(mdbObjs);
         // Problem with making common fieds as sorable is that it REQUIRES a fixed sort order
-        char *sortables[] = {"grant","lab","dataType","cell","strain","age","rnaExtract","localization","phase","treatment","antibody","protocol",
+        char *sortables[] = {"grant","lab","dataType","cell","strain","age","obtainedBy", "rnaExtract","localization","phase","treatment","antibody","protocol",
                       "labProtocolId","restrictionEnzyme","control","replicate","expId","labExpId","setType","view","submittedDataVersion","subId",
                       "dateSubmitted","dateResubmitted","dateUnrestricted","dataVersion"};//"labVersion","softwareVersion",
         // Not included:    no:not searchable
         // accession no, annotation no,   bioRep no,     composite no, controlId no, dccInternalNotes no, fileIndex no,  fileName no,
         // fragSize no,  fragLength no,   freezeDate no, geoSample,    geoSeries,    insertLength no,     labVersion,    level no,
-        // mapAlgorithm, obtainedBy,      origAssembly,  privacy no,   rank no,      readType,            seqPlatform,   sex,
+        // mapAlgorithm, origAssembly,    privacy no,    rank no,      readType,     seqPlatform,         sex,
         // size no,      softwareVersion, tableName no,   uniqueness no
 
         int ix = 0, count = sizeof(sortables)/sizeof(char *);
         for (ix=0;ix<count;ix++)
             {
             // If sortables[ix] is in common vars then then add it to the settings field
             if (mdbObjContains(commonVars,sortables[ix],NULL))
+                {
+                if (mdbRemoveCommonVar(mdbObjs, sortables[ix])) // Don't bother if all the vals are the same
+                    continue;
                 dyStringPrintf(dySortFields,"%s=%s ",sortables[ix],strSwapChar(cloneString(cvLabel(sortables[ix])),' ','_'));
             }
+            }
         if (dyStringLen(dySortFields))
             {
             dyStringAppend(dySortFields,"fileSize=Size fileType=File_Type");
             setting = dyStringCannibalize(&dySortFields);
             }
         else
             dyStringFree(&dySortFields);
         mdbObjsFree(&commonVars);
         }
     if(setting == NULL) // Must be in trackDb or not a sortable list of files
         {
         #define FILE_SORT_ORDER_DEFAULT "cell=Cell_Line lab=Lab view=View replicate=Rep fileSize=Size fileType=File_Type dateSubmitted=Submitted dateUnrestricted=RESTRICTED<BR>Until"
         setting = FILE_SORT_ORDER_DEFAULT;
         }
     sortOrder = needMem(sizeof(sortOrder_t));