TSORT(1)

πŸ“¦ version 1.053, in alpine 3.24

✨ TSORT(1) β€” tsort (topological sort), bestie edition ✨

hey bestie! welcome to the TSORT(1) page from the User Contributed Perl Documentation β€” aka the tsort manual, and yes we’re gonna make topological sorting make sense. πŸ’–


🌸 NAME 🌸

tsort β€” topological sort. That’s the name, that’s the job, and it’s iconic. periodt. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

the whole invocation is literally just:

tsort [filename]

πŸ’– DESCRIPTION πŸ’–

OKAY so tsort does a topological sort of input pairs. It takes input from the standard input if you don’t provide a filename argument β€” no cap, stdin is the default bestie. 🫢

For a more complete description, see the tsort(1) man page. For an explanation of the algorithm, see the Work column in the October, 1998, issue of SunExpert, or the references given below. ✨


πŸ’… OPTIONS AND ARGUMENTS πŸ’…

  • [-b|-d] β€” breadth-first or depth-first traversal; depth-first is the default. Choose your traversal vibe wisely. 🌈
  • filename β€” optional input file. Input format is pairs of white-space-separated fields. Each field is the name of a node. Output is the topologically sorted list of nodes. πŸŽ€

πŸŽ€ AUTHOR πŸŽ€

Jeffrey S. Haemer. Give him his flowers. πŸ’


🌈 SEE ALSO 🌈

Algorithm stolen from Jon Bentley (More Programming Pearls, pp. 20-23), who, in turn, stole it from Don Knuth (Art of Computer Programming, volume 1: Fundamental Algorithms, Section 2.2.3). the algorithm lore is real. πŸ“šβœ¨


πŸ’– xoxo, your Perl bestie β€” this page is from perl v5.42.2, dated 2026-02-15. slay! πŸ’–

πŸ“¦ where this page comes from