Suppose I am sliding a block very slowly on a rough surface. If the block has traveled ##d## distance then work done by me is ##W_1=\mu mg d## and that by friction is ##W_2=-\mu mg d##.
Now the energy transferred from me to block is ##\mu mgd## and that taken by friction from block is ##\mu mgd...