Add sorting functionality.