If there are less than 5 cards in the library, you look at whatever ones remain and you still get the option to shuffle.

Artwork
Loading artwork…
Visions
Fourth Edition · #54 · EN
Nonfoil—Foil—
Card rules
Look at the top five cards of target player's library. You may then have that player shuffle that library.
"Visions of glory, spare my aching sight, Ye unborn ages, crowd not on my soul!" —Thomas Gray, "The Bard"
Uncommon · Illustrated by NéNé Thomas
Format legality
Commander Legal
Duel Legal
Legacy Legal
Oathbreaker Legal
Old School Legal
PreDH Legal
Premodern Legal
Tlr Legal
Vintage Legal
Alchemy Not Legal
Brawl Not Legal
Competitive Brawl Not Legal
Future Not Legal
Gladiator Not Legal
Historic Not Legal
Modern Not Legal
Pauper Not Legal
Pauper Commander Not Legal
Penny Not Legal
Pioneer Not Legal
Standard Not Legal
Standard Brawl Not Legal
Timeless Not Legal
Rulings
Published rulings from the downloaded Scryfall catalog. Source card record · Rules and interactions
You can’t rearrange the cards. You put them back in the same order or have the whole library shuffled.
This is not a draw and will not cause a player to lose if there are less than 5 cards in the library.