Fix bug with function sort($fields)

- fix `isArray` to `is_array`
- remove unecessary `(array)`
- fix `$field` to `$fields`