sorting and deleting functionality