Added functionality to sorting buttons