In formats involving only cards from Urza’s Saga™ and later, players may change the order of their graveyard at any time.
The set Stronghold has the last cards that care about graveyard order. Urza’s Saga is the set following that, so any format that only includes later sets players may change the order of their graveyard.
The most common formats for which players cannot change a graveyard’s order are Legacy & Vintage.
A player may not change the order of an opponent’s graveyard.
A player may look through an opponent’s graveyard whenever they like. Players should always ask for the owner’s permission before touching cards that do not belong to them, as a courtesy. If a player is looking through a graveyard extra care should be taken to not mix any of the cards with their hand.