Type ordering
FQL comparisons are deterministic. Any two values can be compared, even when they do not have the same type.
When two values are compared, FQL first looks at their types. If the types are different, the result is decided by the global type order. The actual values are only compared when both operands have the same type.
FQL uses the following type order:
This means that NONE sorts before every other value, while objects sort after every other built-in value type.
For example, a boolean value always sorts before a number, a string, an array, or an object. A string always sorts after a number, even if the string is empty or contains numeric-looking text.
Once the types are the same, FQL compares the values according to the rules for that type.
Primitive values
Primitive values are ordered as follows:
NONEis only equal toNONE.- Booleans are ordered as false < true.
- Numbers are ordered by numeric value.
- Strings are ordered using FQL’s string comparison rules.
Arrays
Arrays are compared element by element from left to right.
At each position, FQL compares the two elements using the same comparison rules described on this page. If the elements are different, that result decides the array comparison. If the elements are equal, FQL moves to the next position.
If all compared elements are equal, the shorter array sorts first.
Array comparison is recursive. If an element is another array or an object, that nested value is compared using the same rules.
Objects
Objects are compared by their attributes, not by the order in which those attributes were written.
Before two objects are compared, FQL considers their attribute names in sorted order. For each attribute name, FQL compares the corresponding values from both objects.
If one object has an attribute that the other object does not have, the missing value is treated as NONE for comparison purposes.
Attribute declaration order does not affect equality:
If all attributes compare as equal, the objects are considered equal.