Sort functionality implemented