sorted output and wrap in contents