monkey sort and dp