The T.Rex is closer related to birds than to Stegosaurus.

The comic shows it in 3 different aspects:

**Time:**

From the [T.Rex Wiki page](http://en.wikipedia.org/wiki/Tyrannosaurus_rex), it lived during:

>Fossils are found in a variety of rock formations dating to the Maastrichtian age of the upper Cretaceous Period, 67 to 65.5 million years ago.

While the [Stegosaurus](http://en.wikipedia.org/wiki/Stegosaurus) lived:

>They lived during the Late Jurassic period (Kimmeridgian to early Tithonian), some 155 to 150 million years ago in what is now western North America.

Which means that the time period between the T.Rex and the Stego (83 million years) is longer than the time period between the T.Rex existence and the sparrow's (65.5 million years)

**Phylogenetic Distance:**

The [Wiki article for Origin of Birds](http://en.wikipedia.org/wiki/Origin_of_birds) says:

>most researchers now support the view that birds are a group of theropod dinosaurs that evolved during the Mesozoic Era.

The T.Rex is a part of the theropod dinosaurs, while the Stegosaurus isn't, which supports the claim that birds and the T.Rex have a common phylogenetic branch, later than the T.Rex and Stegosaurus.

**Bone Structure:**

There is the [article](http://www.sciencemag.org/content/340/6133/690) linked to by explain XKCD which says that (as the question quotes).

Also, look at the bone structure yourself.

A sparrow:

![dead sparrow](http://media.tumblr.com/tumblr_m27na3UmVt1qa28d3.jpg)

A T.Rex:

![dead trex](http://www.wired.com/images_blogs/wiredscience/2009/08/t-rexskeleton2.jpg)

A Stegosaurus:

![dead stego](http://en.academic.ru/pictures/enwiki/83/Stegosaurus_Senckenberg.jpg)

The bone structure of the sparrow and T.Rex is a lot more similar than the T.Rex and Stegosaurus. They are both bipedal, upright, have small "hands" and more.