naturalstrcmp3
Compare string in alphabetical order for letters and numerical for digits.
Synopsys
#include "mut.h" int naturalstrcmp(s, t) char ∗s, ∗t;
Parameters
s
|
Pointer to the first string to compare |
|---|---|
t
|
Pointer to the second string to compare |
Overview
naturalstrcmp is an alphanumerical comparison function that ensures x12 > x2 for example. First, the alphabetical part of the string is compared, using strcmp(3), then, if it has trailing numbers, they are compared using a numerical function.
Return values
naturalstrcmp has the same return values than the standard library strcmp(3) function.
Examples
#include "mut.h"
static int
connectorcmp(flc, slc)
locon_list **flc, **slc;
{
return naturalstrcmp((*slc)->NAME, (*flc)->NAME);
}
Releases
4 releases since Debian 7 (Wheezy); the text changed 1 time.