add codes function

easier get sort codes