a310de79beafde036d76654f097af974033828ba kent Mon Dec 6 09:12:13 2021 -0800 Adding slPairCmpWordsWithEmbeddedNumbers library routine to support that nice form of sorting in the faceted table display. diff --git src/lib/common.c src/lib/common.c index 4547e7c..d874e27 100644 --- src/lib/common.c +++ src/lib/common.c @@ -1324,30 +1324,39 @@ int slPairCmpCase(const void *va, const void *vb) /* Compare two slPairs, ignore case. */ { const struct slPair *a = *((struct slPair **)va); const struct slPair *b = *((struct slPair **)vb); return strcasecmp(a->name, b->name); } void slPairSortCase(struct slPair **pList) /* Sort slPair list, ignore case. */ { slSort(pList, slPairCmpCase); } +int slPairCmpWordsWithEmbeddedNumbers(const void *va, const void *vb) +/* Sort slPairList ignoring case and dealing with embedded numbers so 2 comes + * before 10, not after. */ +{ +const struct slPair *a = *((struct slPair **)va); +const struct slPair *b = *((struct slPair **)vb); +return cmpWordsWithEmbeddedNumbers(a->name, b->name); +} + int slPairCmp(const void *va, const void *vb) /* Compare two slPairs. */ { const struct slPair *a = *((struct slPair **)va); const struct slPair *b = *((struct slPair **)vb); return strcmp(a->name, b->name); } int slPairValCmpCase(const void *va, const void *vb) /* Case insensitive compare two slPairs on their values (must be string). */ { const struct slPair *a = *((struct slPair **)va); const struct slPair *b = *((struct slPair **)vb); return strcasecmp((char *)(a->val), (char *)(b->val)); }