a3739b776a1dff6f5b07d035faa320d22c975c48 braney Mon Jul 15 14:08:31 2024 -0700 make priority optional in groups.txt. Also actually sort by priority if specified diff --git src/hg/lib/grp.c src/hg/lib/grp.c index 2557ebe..a823e1b 100644 --- src/hg/lib/grp.c +++ src/hg/lib/grp.c @@ -135,30 +135,42 @@ fprintf(f, "%s", el->name); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->label); if (sep == ',') fputc('"',f); fputc(sep,f); fprintf(f, "%f", el->priority); fputc(sep,f); fprintf(f, "%d", el->defaultIsClosed); fputc(lastSep,f); } /* -------------------------------- End autoSql Generated Code -------------------------------- */ +int grpCmpPriorityLabel(const void *va, const void *vb) +/* Compare to sort based on priority and label. */ +{ +const struct grp *a = *((struct grp **)va); +const struct grp *b = *((struct grp **)vb); +double dif = a->priority - b->priority; +if (dif < 0) return -1; +if (dif > 0) return 1; + +return strcmp(a->label, b->label); +} + int grpCmpPriority(const void *va, const void *vb) /* Compare to sort based on priority. */ { const struct grp *a = *((struct grp **)va); const struct grp *b = *((struct grp **)vb); double dif = a->priority - b->priority; if (dif < 0) return -1; if (dif > 0) return 1; return 0; } int grpCmpName(const void *va, const void *vb) /* Compare to sort based on name. */ { const struct grp *a = *((struct grp **)va);