add sorting functionality