Fix Database::_sort outputs empty ORDER BY clauses

Will not output ORDER BY clause if given field is empty (ie. if  = array()).

Fixes #986.