fixing sorting and deleting blank entries