std::sort is returning a slightly different sort order when label z order (or label cost) is equal Given that the order in these cases is effectively arbitrary I've updated the test masks to accept either order.