Shuffle Lines
Randomly shuffle the lines of any text instantly. Perfect for randomizing lists, quiz questions, or dataset rows.
0 lines
0 lines
Common Use Cases
About Shuffle Lines
Randomly shuffling a list is one of those operations that sounds trivial but comes up constantly in real workflows. Educators randomise quiz questions and answer choices to prevent cheating and pattern recognition. Developers randomly order test cases or fixtures to catch order-dependent bugs that would otherwise go unnoticed. Data scientists shuffle rows in a CSV before splitting into training and validation sets, ensuring neither set is biased toward a particular ordering in the source data. Technical interviewers shuffle candidate lists to ensure fair random assignment to interviewers.
The underlying algorithm used here is the Fisher-Yates shuffle (also known as the Knuth shuffle), published by Ronald Fisher and Frank Yates in 1938 and adapted for computers by Donald Knuth. The algorithm produces a uniformly random permutation — every possible ordering of N items is equally likely. It runs in O(n) time and O(1) extra space by performing in-place swaps from the last element down to the first, each time picking a random position from the remaining unshuffled prefix. Naïve approaches like sorting by Math.random() or repeatedly picking a random unused element both produce biased distributions and are slower.
The "ignore empty lines" option is useful when pasting lists that have blank separator lines between items — stripping them ensures blank rows don't count as list entries or end up awkwardly redistributed in the output. The "trim whitespace" option handles lists pasted from spreadsheets or editors where trailing spaces or leading indentation crept in.
This tool is also handy for generating random orderings for tabletop games, selecting a random starting player from a list of names, or simply breaking alphabetical ordering in a presentation slide to avoid audiences anticipating the next item.