Fix bug in sortIdx_type so that it returns error always