the text file is something like this:
// Signals:
// ac_mode
// ac_test
// active_mode
// adden
// analog_test_enable
// apf_user_control
// arce
// arclr
// arin
// aux_msel[1]
// auxmsel_ctl
// ....
// ....
PI="XXXXXXXXX0XXXXX01XXXXXXXXXXXX0XXX0XXXXXX0XX0X00XXXXXXXXXXXXX00XX00XXXXX
*the ac_mode correspond to X ( x means Out), ac_test correspond to the second x , the third 1 active mode correspond to the third at PI which is X also, means Out as well. Then sorting by In 1st then follow by Out. the output should be: Signals { "aux_msel[1]" In; "aux_msel[0]" In; "clkusr" In; "condonei" In; "datai[7]" In; "analog_test_enable" Out; "apf_user_control" Out; "arce" Out; "arclr" Out; "arin" Out; where X is represent Out and 0 or 1 represent IN."