fix undo() bug, add warning, add sort tasks