Fix view tree sorting by ensuring that the buffer always exists