Fix prioritySort for priority = 0

For #1882 and #1876