b3d7beaa964c90d43a6acea6292f34eef5cd1b4d
angie
  Wed Dec 18 16:10:12 2019 -0800
In pack mode, sorting by position at draw time is too late -- items have been packed before draw time, so sort by position at load time.

diff --git src/hg/hgTracks/variation.c src/hg/hgTracks/variation.c
index 7a97ccb..e787581 100644
--- src/hg/hgTracks/variation.c
+++ src/hg/hgTracks/variation.c
@@ -2871,30 +2871,31 @@
     }
 return minMaf;
 }
 
 static void bigDbSnpLoadItems(struct track *tg)
 /* Convert bigDbSnp items in window to linkedFeatures. */
 {
 struct linkedFeatures *lfList = NULL;
 double minMaf = getMinMaf(tg->tdb);
 // If minMaf is 0, there's no need to filter so set freqSourceIx to -1.
 int freqSourceIx = (minMaf == 0.0) ? -1 : getFreqSourceIx(tg->tdb);
 char *maxItemStr = trackDbSetting(tg->tdb, "maxItems");
 int maxItems = isNotEmpty(maxItemStr) ? atoi(maxItemStr) : 250000;
 bigBedAddLinkedFeaturesFromExt(tg, chromName, winStart, winEnd, freqSourceIx, 0, FALSE, 4, &lfList,
                                maxItems);
+slReverse(&lfList);
 // if the summary is filled in then the number of items in the region is greater than maxItems.
 if (tg->summary != NULL)
     {
     // too many items to display
     tg->drawItems = bigDrawWarning;
     tg->networkErrMsg = "Too many variants in display (zoom in to see details)";
     tg->totalHeight = bigWarnTotalHeight;
     tg->items = NULL;
     }
 else
     tg->items = lfList;
 }
 
 static Color bigDbSnpColor(struct track *tg, void *item, struct hvGfx *hvg)
 /* Return color stashed away in lf->filterColor. */
@@ -3030,31 +3031,30 @@
 
 void bigDbSnpDraw(struct track *tg, int seqStart, int seqEnd,
                   struct hvGfx *hvg, int xOff, int yOff, int width,
                   MgFont *font, Color color, enum trackVisibility vis)
 /* Draw linked features items. */
 {
 if (vis == tvDense ||
     (tg->limitedVisSet && tg->limitedVis == tvDense))
     {
     // Sort so that items with the strongest colors appear on top.
     slSort(&tg->items, lfColorCmp);
     }
 else
     {
     // Sort by position as usual
-    slReverse(&tg->items);
     slSort(&tg->items, linkedFeaturesCmp);
     }
 genericDrawItems(tg, seqStart, seqEnd, hvg, xOff, yOff, width, font, color, vis);
 }
 
 void bigDbSnpMethods(struct track *track)
 /* Special load and draw hooks for type bigDbSnp. */
 {
 linkedFeaturesMethods(track);
 track->canPack = TRUE;
 track->loadItems = bigDbSnpLoadItems;
 track->drawItems = bigDbSnpDraw;
 track->drawItemAt = bigDbSnpDrawItemAt;
 track->itemColor = bigDbSnpColor;
 track->itemNameColor = bigDbSnpColor;