How do I sort a Numbers' table using data from another table?
Thanks to your sample file, I think I was able to do what you wished.

Using an additional column to bring in the numbers corresponding to the codes (16AA, 1; 16AE, 2...) sorting by that column then hiding it the desired result was accomplished.  To refresh the sort after adding data, unhide the column and sort again.

Here are the steps:


Create new column to the left of the "Code" column.

Add a formula to extract the proper number for each code and copy down.

Formula: =INDEX (Group::c, MATCH (B, Group::A))


(Using INDEX(MATCH) is a good way to get column data with out worrying about extra columns being added as is the case with VLOOKUP.)


Copy the formula down, sort the column and hide it if desired.


Result: