Fix bugs in SortBlock.