Recursively sort object keys before hashing.
Use isPrimitive() for object type test.