Fix com.mongodb.MongoException: Can't canonicalize query: BadValue bad sort specification.
Cleanup code.