UNSORT(1)

πŸ’… unsort(1) πŸ’…

okay so this is unsort, from the General Commands Manual (section 1, the classics πŸ’–). bestie, this little icon reorders the lines in your file in semirandom ways and honestly? it ate. let's get into it.


✨ NAME ✨

unsort β€” reorder lines in a file in semirandom ways


πŸ¦‹ SYNOPSIS πŸ¦‹

unsort [-hvrpncmMsz0l] [--help] [--version] [--random] [--heuristic]
       [--identity] [--filenames[=profile]] [--separator sep]
       [--concatenate] [--merge] [--merge-random] [--seed integer]
       [--zero-terminated] [--null] [--linefeed] [file ...]

🌸 DESCRIPTION 🌸

unsort prints the lines from the input files (or from standard input, if you don't name any files) in semi-random order. the vibes are shuffled but not fully chaotic, periodt.

the algorithms on offer are:

  • a Mersenne Twister based PRNG (the fancy math one πŸ”₯)
  • a heuristic algorithm that's out here trying to create a subjective even distribution (she wants things spread out pretty, she has a vision ✨)

πŸŽ€ Command line options πŸŽ€

  • -h, --help β€” shows you a concise lil summary of the available options and the argument syntax. your "what do i even type" bestie 🫢
  • -v, --version β€” displays version and copyright info. the receipts πŸ’œ
  • -r, --random β€” use the Mersenne Twister based randomization algorithm. pure PRNG energy.
  • -p, --heuristic β€” use the heuristic "shuffling" algorithm, which permutes the lines so they end up spread more or less evenly in the output. this one is the default πŸ‘‘
  • -n, --identity β€” do not reorder the lines in the input at all. literally useful if you just want to merge the files. no shuffling, just vibes preserved πŸ™ˆ
  • -f, --filenames[=profile] β€” assumes the input has a structure similar to filenames, and applies randomization separately to each directory level. this one is the main character fr fr.

an example would be a list of mp3 files where the top level is the genre, the second level is the name of the artist and the third level is the name of the album. the --filenames option lets you randomize the list with different randomization strategies for each of the artist, album and track levels. 🎧

two types of randomization are supported: simple and proportional.

  • simple randomization picks one entry from each directory at that level in a round-robin fashion. if one directory contains fewer entries than the others, it will run out and stop appearing at some point before the end of the output. she just runs out of material, it happens 😭
  • proportional randomization will spread the directory entries evenly over the output. balanced, gorgeous, icon behaviour.

the profile argument can be used to specify which randomization types to use. it is a concatenation of the randomization types to use for each level. use 1 for simple randomization and n for proportional randomization. if the input has more levels than specified, the last character determines the randomization type for all subsequent levels. no cap.

for example, --filenames=n1n means: use proportional randomization for the genre, use simple randomization for the artists and use proportional randomization again for the album names and all levels below that. slay 🌈

  • -S, --separator sep β€” the directory separator to use with -f. defaults to /. πŸŽ€
  • -r, --concatenate β€” concatenate all input files, then apply the shuffling algorithm to the result as a whole. one big pile, then shuffle.
not me noticing that -r is listed for both --random and --concatenate πŸ’€ that's exactly how this page reads, so I'm not touching it. iykyk.
  • -m, --merge β€” shuffle all input files separately, then merge the result. equal-sized files will be merged in the order in which they appear on the command line. queue up in order, besties 🧚
  • -M, --merge-random β€” shuffle all input files separately, then merge the result. equal-sized files will be merged in random order. this is the default πŸ‘‘
  • -s, --seed integer β€” use this integer as a seed, instead of random data from the environment. reproducible chaos, obsessed ✨
  • -z, --zero-terminated, -0, --null β€” lines are terminated with a \0 character. null bytes, not newlines, got it 🫢
  • -l, --linefeed β€” lines are terminated with a \n character. this is the default πŸ’–

πŸ‘‘ SEE ALSO πŸ‘‘

sort(1) β€” the responsible older sibling. go say hi.


and that's the whole page, bestie!! this one's from Free Software, dated 2007-11-25, and it lives under the name UNSORT(1) in section 1 of the manual. go forth and shuffle responsibly πŸ¦‹πŸ’–βœ¨