Ensure that .sort method change criteria

This is not working on the latest version of mongoid:
```ruby
 UserThemeVersion.where(parent_id: theme.id, user: current_user.id).sort(version: -1).first
```
it was ignoring the sort on the first query.

This pull request fix that issue. and also:

1- .sort method was not changing the criteria, so when .first applied it assumed there was no sort and it was ignoring it

2 - making apply_sorting a block function to unsure it will reset the query after execution of .first or .last