Sort the Dinosaurs by Weight

Run the code to get the list of dinosaurs known to the Wolfram Language:

SHOW/HIDE DETAILS

This gets a list of dinosaurs and gives it the name dinosaurs. The output is automatically shortened because it’s very long:

In[1]:=

X

Out[1]=

There are a lot of dinosaurs in the list:

In[2]:=

X

Out[2]=

HIDE DETAILS

In[1]:=

X

Out[1]=

Get a picture of a dinosaur. Try other dinosaurs:

Note: run the code in the previous step first.

SHOW/HIDE DETAILS

This gives the second dinosaur in the list:

In[1]:=

X

Out[1]=

Each dinosaur has a wealth of information associated with it, which you can retrieve with EntityValue. Here’s an image of the second dinosaur:

In[2]:=

X

Out[2]=

HIDE DETAILS

In[1]:=

X

Out[1]=

Get the name, an image, and the weight of a dinosaur. Try other dinosaurs:

SHOW/HIDE DETAILS

Get the weight of the second dinosaur:

In[1]:=

X

Out[1]=

Get the name, an image, and the weight of the second dinosaur:

In[2]:=

X

Out[2]=

Sometimes data may be missing. The weight of the first dinosaur is not available:

In[3]:=

X

Out[3]=

HIDE DETAILS

In[1]:=

X

Out[1]=

Make a table of names, pictures, and weights of random dinosaurs. Run the code again to get different dinosaurs:

SHOW/HIDE DETAILS

Get a random sample of 10 dinosaurs. Run the code again to get a different sample:

In[1]:=

X

Out[1]=

Get the name, image, and weight of a random sample of dinosaurs:

In[2]:=

X

Out[2]=

Format the dinosaur data as a table:

In[3]:=

X

Out[3]=

HIDE DETAILS

In[1]:=

X

Out[1]=

Sort the table by weight. Run the code again to get different dinosaurs:

SHOW/HIDE DETAILS

Weights in the table are both single values, like , and ranges, like . To sort the table by weight, you have to first convert the ranges to single values. You can do that easily with a rule that replaces intervals with their average values (their “means”):

In[1]:=

X

Out[1]=

Now you can sort the data by weight, which is the last element of each entry:

In[2]:=

X

Out[2]=

Make a table sorted by weight:

In[3]:=

X

Out[3]=

HIDE DETAILS

In[1]:=

X

Out[1]=

Share It—Put the dinosaur table online, where anyone can visit it.

Note: run the code in the very first step first to define dinosaurs.

SHOW/HIDE DETAILS

Deploy the dinosaur table to the Wolfram Cloud, where anyone can visit it. The table updates each time it’s visited:

In[1]:=

X

Out[1]=

Click the link in the output to visit the site. Refresh the page in your browser to get a new table.

Share the link by right-clicking it and choosing Copy Address. Paste the link into an email, tweet, or other message.