Adding sorting functionality.