# GLib.Variant.prototype.compare

```
function compare(two: GLib.Variant): Number(gint) {
// Gjs wrapper for g_variant_compare()
}
```

Compares one and two.

The types of one and two are #gconstpointer only to allow use of this function with GLib.Tree, GLib.PtrArray, etc. They must each be a GLib.Variant.

Comparison is only defined for basic types (ie: booleans, numbers, strings). For booleans, false is less than true. Numbers are ordered in the usual way. Strings are in ASCII lexographical order.

It is a programmer error to attempt to compare container values or two values that have types that are not exactly equal. For example, you cannot compare a 32-bit signed integer with a 32-bit unsigned integer. Also note that this function is not particularly well-behaved when it comes to comparison of doubles; in particular, the handling of incomparable values (ie: NaN) is undefined.

If you only require an equality comparison, GLib.Variant.prototype.equal is more general.

Since 2.26

- two
a GLib.Variant instance of the same type

- Returns
negative value if a < b; zero if a = b; positive value if a > b.