Fixing sorting and boundary set.