local tableC = {} for k,v in pairs(tableB) if tableA[v] then tableC[k] = v end end table.sort(tableC)