This is… not obvious. It's only easy if you want the simplistic approach of sorting lexicographically or numerically. But in more complex tables, you will often encounter cases where the data representation for sorting is different from data representation for display.

Of course most JavaScript-based tables get this wrong, too.

You could have a `sortkey` attribute, a bit like <option> that has a `value` attribute in case the value you want is different from the value you display.