I spoke too soon and it turns out @stefan-ok’s answer above is spot-on.
I didn’t realize the role of ‘key’ for each cell plays in sorting. According to the documentation of Dynamic table :
Sorting a dynamic table is done based on the
key
set on each cell.
This means I had to include the actual differentiating value of the cell content in the keys in order for sorting to work properly.