HPCC-10749 Revise based on code review

1. Clone 'unknownAttributes'; 2. Use sortElements to avoid duplicated
code; 3. Move 'cSort sort' into block; 4. Use simple array lookup.