rebuild after a sort