Sorting rewritten and deletion added