Added sorting of blocks array