I want to create some rows and columns of data for a site and allow the user to click on a column to organize the data by that column, like so:

_____
a|1|x|
b|3|z|
c|4|y|
d|2|w|
-------

in the above example, the first column is organized.
If the user were to click on the header of the second column, the data would change to:

_____
a|1|x|
d|2|w|
b|3|z|
c|4|y|
------

so that the second column is now in order, and so on.

So my question is this: I don't have any clue how to even start this kind of thing, programmaticaly. Something in the back of my mind tells me that I'll need a multi-dimensional array, but I'm not sure if I should be listening to myself.

I don't want a full tutorial (unless someone happens to know of one that's floating around out there), but the functions that I should be using and a little help on the basic theory of what the heck I'm doing would thrill me to my cold, dark heart.