06c5aff972165106c796ce5504930f8edc9446e3 angie Fri Apr 5 15:49:20 2013 -0700 Moving annoRowCmp from oneShot to annoRow.[ch]. diff --git src/lib/annoRow.c src/lib/annoRow.c index 98d3ae6..f2f38ae 100644 --- src/lib/annoRow.c +++ src/lib/annoRow.c @@ -92,15 +92,31 @@ } void annoRowFreeList(struct annoRow **pList, struct annoStreamer *source) /* Free a list of annoRows. */ { if (pList == NULL) return; struct annoRow *row, *nextRow; for (row = *pList; row != NULL; row = nextRow) { nextRow = row->next; annoRowFree(&row, source); } *pList = NULL; } + +int annoRowCmp(const void *va, const void *vb) +/* Compare two annoRows' {chrom, start, end}. */ +{ +struct annoRow *rowA = *((struct annoRow **)va); +struct annoRow *rowB = *((struct annoRow **)vb); +int dif = strcmp(rowA->chrom, rowB->chrom); +if (dif == 0) + { + dif = rowA->start - rowB->start; + if (dif == 0) + dif = rowA->end - rowB->end; + } +return dif; +} +