words query with additional lexicographical sorting criteria
minor improvements