https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2039924/
http://neuralcircuits.uwm.edu/sharp-wave-ripples/
In summary, the hippocampus will organize neurons into clumps which encode spatial dimension. As a rat runs around throughout a track, certain groups of neurons fire[1] depending on where the rat is located. Before the task even starts, hippocampal neurons in a rat actually fire in quick succession (e.g. ABCDEFG). When the task is completed, the same pattern fires in the reverse order (e.g. GFEDCBA). Scientists believe that these SPWs play an important role in memory consolidation.
I have always thought of this as "the rat is thinking about where it's going to run to". So I started learning machine learning and landed on things like RBMs. I was so excited because RBMs are reminiscent of this actual phenomenon that occurs in the brain. So, I asked Hinton about it because this is no mere coincidence, and he told me that he had a theory that required reverse order firing during sleep state.
If you get a ton of new memories and patterns during wake, sleep may be responsible for not only pruning less important memories, but strengthening more important memories. For example, sleep might be asking the brain for a ranked list of memories, and then strengthens the memories above some threshold, and prunes the rest (just an idea).
[1] Synchronized firing, see Kuramoto coupled differential equations: https://en.wikipedia.org/wiki/Kuramoto_model