ENVI^ ForceLocal=1
IFEX  %&CurFile%.LOG, LOGS %&CurFile%.LOG
SET &VS=
SET$ &NL=0d 0a
ADSL-wlan  ,,list,&&VS

SORTTABL &&VS2 &VS 2 ">"  "#"  "*"



MESS. %&VS2%


//SORTTABL 多行串 排序
//iCol: 默认1，排序列
//CMPOp:默认>:大到小  <:小--->大
//CmpCmd: 默认#:INT $:Float |:String
//CmdItem:默认空格间隔  *:TAB间隔
_SUB SORTTABL // [RetName] OrgName iCol[=]  "CMPOp[>|<][>]"  "CmpCmd[#][#]" "CmdItem[*]|[]" 
    SET~  &VS=%~2
    ^CALC #&&iCol=%~3
    IFEX #%iCol%<=0, SET iCol=1
    SET &Vx=
    SET &I=0
    FORX *NL &VS,&&Vi, TEAM CALC I=%I%+1| SET &V[%I%].v=%Vi% 
    SET &N=%I%
    
    FIND $'<'<>'%~4', SET &CMPOp=<! SET &CMPCmd=>
    FIND $'$'='%~5', SET &CMPCmd=IFEX $! FIND $'|'='%~5', SET &CMPCmd=FIND $! SET &CMPCmd=IFEX #
    SET &CmdItem=MSTR%~6

    SET CMPOp=>
    //SORT ...
    SET I=1
    LOOP #%I%<=%N%,
    {*
        CALC  #&&J=%I%+1
        %CmdItem%  * &&qi=<~%iCol%>V[%I%].v
        SET~ vi=V[%I%].v
        LOOP #%J%<=%N%,
        {*  %CmdItem%  * &&qj=<~%iCol%>V[%J%].v
            %CMPCmd%%%qj%%%CMPOp%%%qi%%, @TEAM SET~ qi=qj| SET-swap V[%I%].v=V[%J%].v  
            CALC #J=%J%+1
        }
        CALC #I=%I%+1
    }
    ///SORT END
    //^MESS. %%&V[1].v%%
    SET &Vx=
    SET I=1
    LOOP #%I%<=%N%,
    {
        ^SET< Vx=%NL%%%V[%I%].v%%
        CALC  #&I=%I%+1
    }
    MSTR * &&Vx3=3,0,Vx
    FIND $%~1<>, ENVI-ret~ %~1=&Vx3! ENVI-ret~ %~2=&Vx3
_END



