Fix sorting

This PR fixes document sorting with the format:
`sort=(+type,-name)`