<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Tim's blog (Posts about tsort)</title><link>https://blog.thechases.com</link><description></description><atom:link href="https://blog.thechases.com/categories/tsort.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2025 &lt;a href="mailto:blog@tim.thechases.com"&gt;Tim Chase&lt;/a&gt; </copyright><lastBuildDate>Thu, 02 Oct 2025 19:32:44 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Planning the day on the CLI with tsort</title><link>https://blog.thechases.com/posts/planning-the-day-on-the-cli-with-tsort/</link><dc:creator>Tim Chase</dc:creator><description>&lt;p&gt;
I had a bunch of items on the todo list for the day
and wanted to arrange them in order,
but I needed to certain items before others:

 &lt;/p&gt;&lt;ul&gt;
  &lt;li&gt;
   Drop donations off at the resale store,
   but can't do that before 10:00 when they open
  &lt;/li&gt;
  &lt;li&gt;
   Get the daughter ready for soccer camp before dropping her off
  &lt;/li&gt;
  &lt;li&gt;
   Drop the daughter off at camp
   before taking paperwork up to her school
  &lt;/li&gt;
  &lt;li&gt;
   cut the son's hair
   before he
   takes a shower
   and
   cleans his bathroom
  &lt;/li&gt;
  &lt;li&gt;
   pick up daughter at camp
   after she's started camp (duh)
   and before 10:45
  &lt;/li&gt;
  &lt;li&gt;
   take the kids to the library
   after picking up daughter at camp
  &lt;/li&gt;
  &lt;li&gt;
   for obvious reasons,
   8:30 → 8:45 → 9:00 → 10:00 → 10:30 → 10:45
  &lt;/li&gt;
 &lt;/ul&gt;

So I expressed this in a file
where each row contains
"X needs to come before Y":

&lt;pre&gt;
&lt;label&gt;$ &lt;/label&gt;cat todo.txt
10:00 resale
resale 10:30
sunblock take_to_camp
pack_snack take_to_camp
pack_water take_to_camp
pack_towel take_to_camp
take_to_camp 8:30
8:30 soccer_camp
soccer_camp 8:45 
soccer_camp paperwork
8:45 home
home 9:00
paperwork home
home cut_hair
home clean_bathroom
home shower
cut_hair shower
cut_hair pick_up
shower pick_up
clean_bathroom pick_up
cut_hair clean_bathroom
clean_bathroom 10:00
10:45 pick_up
8:30 8:45 
8:45 9:00 
9:00 10:00 
10:00 10:30 
10:30 10:45 
pick_up library
&lt;/pre&gt;


&lt;p&gt;
Now it just became a matter of passing these requirements to
&lt;code&gt;tsort&lt;/code&gt;
&lt;/p&gt;&lt;pre&gt;
&lt;label&gt;$ &lt;/label&gt;tsort todo.txt
pack_towel
pack_water
pack_snack
sunblock
take_to_camp
8:30
soccer_camp
paperwork
8:45
home
cut_hair
9:00
shower
clean_bathroom
10:00
resale
10:30
10:45
pick_up
library
&lt;/pre&gt;
to sift them into the required order
of my todo list for the day.</description><category>tsort</category><guid>https://blog.thechases.com/posts/planning-the-day-on-the-cli-with-tsort/</guid><pubDate>Mon, 31 Jul 2023 12:48:08 GMT</pubDate></item></channel></rss>