Next / Previous / Contents / TCC Help System / NM Tech homepage

20.8. cmp(): Compare two values

This function compares the values of two arguments x and y:

cmp(x, y)

The return value is:

The built-in cmp() function will typically return only the values -1, 0, or 1. However, there are other places that expect functions with the same calling sequence, and those functions may return other values. It is best to observe only the sign of the result.

>>> cmp(2,5)
-1
>>> cmp(5,5)
0
>>> cmp(5,2)
1
>>> cmp('aardvark', 'aardwolf')
-1