The memories in your brain will undergo segregation while you are sleeping. The brain will decide which memories should belong to long-term or short-term memories and which short-term memories should be erased so you can have new memories to store. Moreover, certain stages of sleep have various roles in consolidating different types of memories and sleep deprivation can affect how certain memories are consolidated, making it difficult for someone to learn, remember bits of events, information or retain old memories.