---
name: "naturalstrcmp"
section: "3"
platform: "linux"
package: "alliance"
version: "5.1.1-3"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/naturalstrcmp"
---

# naturalstrcmp(3)

compare string in alphabetical order for letters and numerical for digits.

## NAME

naturalstrcmp - 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

## DESCRIPTION

**naturalstrcmp** is an alphanumerical comparison function that ensures **x12 \> x2** for example. First, the alphabetical part of the string is compared, using [**strcmp**(3)](/strcmp/3.md), 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)](/strcmp/3.md) function.

## EXAMPLE

```
#include "mut.h"
static int
	connectorcmp(flc, slc)
locon_list **flc, **slc;
{
	return naturalstrcmp((*slc)->NAME, (*flc)->NAME);
}
```

## SEE ALSO

**mbk**(1), [**strcmp**(3)](/strcmp/3.md).
