Add sorting and assemble