Sanding normally takes place before priming. Sanding walls before priming is for smooth (non textured) surfaces that have hard glossy coats. This practice does help the primer adhere but modern acrylic primer do a great job without sanding.
The best practice is washing the walls to remove any dust or greasy films. This alone can make a big difference.