Fix incorrect sort direction index