update with sorting