ac0d694dd1b7a53bd182b9555048eaa3fb0bf512 braney Sun Jun 2 14:31:20 2019 -0700 sort myHub list alphabetically by shortLabel diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c index 72dd40b..f89faa8 100644 --- src/hg/hgHubConnect/hgHubConnect.c +++ src/hg/hgHubConnect/hgHubConnect.c @@ -1508,30 +1508,41 @@ if (errCatchStart(errCatch)) { hubAddTracks(hub, database); } errCatchEnd(errCatch); if (errCatch->gotError) { hub->errorMessage = cloneString(errCatch->message->string); hubUpdateStatus( errCatch->message->string, hub); } else hubUpdateStatus(NULL, hub); } } +int hubConnectStatusCmp(const void *va, const void *vb) +/* Compare to sort based on shortLabel */ +{ +const struct hubConnectStatus *a = *((struct hubConnectStatus **)va); +const struct hubConnectStatus *b = *((struct hubConnectStatus **)vb); +struct trackHub *ta = a->trackHub; +struct trackHub *tb = b->trackHub; + +return strcasecmp(tb->shortLabel, ta->shortLabel); +} + void doMiddle(struct cart *theCart) /* Write header and body of html page. */ { cart = theCart; if(cgiIsOnWeb()) checkForGeoMirrorRedirect(cart); if (cartVarExists(cart, hgHubDoClear)) { doClearHub(cart); cartWebEnd(); return; } @@ -1581,30 +1592,32 @@ getDbAndGenome(cart, &database, &organism, oldVars); char *survey = cfgOptionEnv("HGDB_HUB_SURVEY", "hubSurvey"); char *surveyLabel = cfgOptionEnv("HGDB_HUB_SURVEY_LABEL", "hubSurveyLabel"); if (survey && differentWord(survey, "off")) hPrintf("<span style='background-color:yellow;'><A HREF='%s' TARGET=_BLANK><EM><B>%s</EM></B></A></span>\n", survey, surveyLabel ? surveyLabel : "Take survey"); hPutc('\n'); // grab all the hubs that are listed in the cart struct hubConnectStatus *hubList = hubConnectStatusListFromCartAll(cart); checkTrackDbs(hubList); +slSort(&hubList, hubConnectStatusCmp); + // here's a little form for the add new hub button printf("<FORM ACTION=\"%s\" NAME=\"addHubForm\">\n", "../cgi-bin/hgHubConnect"); cgiMakeHiddenVar("hubUrl", ""); cgiMakeHiddenVar( hgHubDoFirstDb, "on"); cgiMakeHiddenVar( hgHubDoRedirect, "on"); cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on"); cartSaveSession(cart); puts("</FORM>"); // this is the form for the connect hub button printf("<FORM ACTION=\"%s\" NAME=\"connectHubForm\">\n", "../cgi-bin/hgHubConnect"); cgiMakeHiddenVar("hubUrl", ""); cgiMakeHiddenVar("db", ""); cgiMakeHiddenVar( hgHubDoRedirect, "on"); cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on");