sort function update