private static function sortTerms($a, $b)
    {
        $lenA = strlen($a);
        $lenB = strlen($b);

        if ($lenA < $lenB) {
            return -1;
        } elseif ($lenA === $lenB) {
            return strcmp($a, $b);
        } else {
            return 1;
        }
    }
private static function sortTerms($a, $b)
    {
        $lenA = strlen($a);
        $lenB = strlen($b);

        if ($lenA < $lenB) {
            return -1;
        } elseif ($lenA === $lenB) {
            return strcmp($a, $b);
        } else {
            return 1;
        }
    }
private static function sortTerms ( $ a , $ b ) { $ lenA = strlen ( $ a ) ; $ lenB = strlen ( $ b ) ; if ( $ lenA < $ lenB ) { return - 1 ; } elseif ( $ lenA === $ lenB ) { return strcmp ( $ a , $ b ) ; } else { return 1 ; } }
Compares two values by their length and then lexicographically

If two strings have different lengths, the shorter one will be
considered less than the other. If they have the same length, they
are compared lexicographically.

@param mixed $a Value A.
@param mixed $b Value B.

@return int If value A is shorter than value B, -1 will be returned; if it's
longer 1 will be returned. If both values have the same length
and value A is considered lexicographically less, -1 will be
returned, if they are equal 0 will be returned, otherwise 1
will be returned.
Compares two values by their length and then lexicographically