Changes to update sorting algorthim.