Prevent not allowed sort directions

sortdir should be verified, because if sortdir have wrong value (i.e. from malicious request),  KeyError raised.