-writefile("badger.mdwn", "t/tmp/in", "[[!meta title=\"The Breezy Badger\"]]\ncontent of badger");
-writefile("mushroom.mdwn", "t/tmp/in", "content of mushroom");
-writefile("snake.mdwn", "t/tmp/in", "content of snake");
-writefile("ratty.mdwn", "t/tmp/in", "content of ratty");
-writefile("mr_toad.mdwn", "t/tmp/in", "content of mr toad");
-writefile("add.mdwn", "t/tmp/in", '[[!trail pagenames="add/a add/b add/c add/d add/e"]]');
-writefile("add/b.mdwn", "t/tmp/in", "b");
-writefile("add/d.mdwn", "t/tmp/in", "d");
-writefile("del.mdwn", "t/tmp/in", '[[!trail pages="del/*" sort=title]]');
-writefile("del/a.mdwn", "t/tmp/in", "a");
-writefile("del/b.mdwn", "t/tmp/in", "b");
-writefile("del/c.mdwn", "t/tmp/in", "c");
-writefile("del/d.mdwn", "t/tmp/in", "d");
-writefile("del/e.mdwn", "t/tmp/in", "e");
-writefile("self_referential.mdwn", "t/tmp/in", '[[!trail pagenames="self_referential" circular=yes]]');
-
-writefile("meme.mdwn", "t/tmp/in", <<EOF
+write_old_file("badger.mdwn", "[[!meta title=\"The Breezy Badger\"]]\ncontent of badger");
+write_old_file("mushroom.mdwn", "content of mushroom");
+write_old_file("snake.mdwn", "content of snake");
+write_old_file("ratty.mdwn", "content of ratty");
+write_old_file("mr_toad.mdwn", "content of mr toad");
+write_old_file("add.mdwn", '[[!trailitems pagenames="add/a add/b add/c add/d add/e"]]');
+write_old_file("add/b.mdwn", "b");
+write_old_file("add/d.mdwn", "d");
+write_old_file("del.mdwn", '[[!trailitems pages="del/*" sort=title]]');
+write_old_file("del/a.mdwn", "a");
+write_old_file("del/b.mdwn", "b");
+write_old_file("del/c.mdwn", "c");
+write_old_file("del/d.mdwn", "d");
+write_old_file("del/e.mdwn", "e");
+write_old_file("self_referential.mdwn", '[[!trailitems pagenames="self_referential" circular=yes]]');
+write_old_file("sorting/linked.mdwn", "linked");
+write_old_file("sorting/a/b.mdwn", "a/b");
+write_old_file("sorting/a/c.mdwn", "a/c");
+write_old_file("sorting/z/a.mdwn", "z/a");
+write_old_file("sorting/beginning.mdwn", "beginning");
+write_old_file("sorting/middle.mdwn", "middle");
+write_old_file("sorting/end.mdwn", "end");
+write_old_file("sorting/new.mdwn", "new");
+write_old_file("sorting/old.mdwn", "old");
+write_old_file("sorting/ancient.mdwn", "ancient");
+# These three need to be in the appropriate age order
+ok(utime(333333333, 333333333, "t/tmp/in/sorting/new.mdwn"));
+ok(utime(222222222, 222222222, "t/tmp/in/sorting/old.mdwn"));
+ok(utime(111111111, 111111111, "t/tmp/in/sorting/ancient.mdwn"));
+write_old_file("sorting/linked2.mdwn", "linked2");
+# This initially uses the default sort order: age for the inline, and path
+# for trailitems. We change it later.
+write_old_file("sorting.mdwn",
+ '[[!traillink linked]] ' .
+ '[[!trailitems pages="sorting/z/a or sorting/a/b or sorting/a/c"]] ' .
+ '[[!trailitems pagenames="sorting/beginning sorting/middle sorting/end"]] ' .
+ '[[!inline pages="sorting/old or sorting/ancient or sorting/new" trail="yes"]] ' .
+ '[[!traillink linked2]]');
+
+write_old_file("meme.mdwn", <<EOF