#include #include Func SortMe($filename) _SQLite_Startup() _SQLite_Open() OnAutoItExitRegister('_fini') Local $ret = _SQLite_Exec(-1, 'CREATE TABLE if not exists [t1] (c1, c2);') If $ret <> $SQLITE_OK Then Exit (MsgBox(0, 'SQLITE ERROR', 'Create Temp Table Failed')) ; load temp table t1 Local $aFile = StringSplit(FileRead($filename), @CRLF, 3), $sql = 'insert into t1 values ' For $1 = 0 To UBound($aFile) - 1 If $aFile[$1] = '' Then ContinueLoop ; prefix sort order control byte Switch True Case StringRegExp($aFile[$1], '^M.*') $aFile[$1] = '0' & $aFile[$1] Case StringRegExp($aFile[$1], '^LCSD.*') $aFile[$1] = '1' & $aFile[$1] Case StringRegExp($aFile[$1], '^LCS-.*') $aFile[$1] = '2' & $aFile[$1] Case Else $aFile[$1] = '3' & $aFile[$1] EndSwitch $sql &= '(' & _SQLite_FastEscape(StringRegExpReplace($aFile[$1], '(.*?) .*', '$1')) & ', ' & _SQLite_FastEscape(StringRegExpReplace($aFile[$1], '.*? (.*)', '$1')) & '),' & @CRLF Next $sql = StringTrimRight($sql, 3) & ';' _SQLite_Exec(-1, $sql) If @error Then Exit MsgBox(0, '', _SQLite_ErrMsg()) ; get rid of dup entries...stor result in table t2 Local $ret = _SQLite_Exec(-1, 'CREATE TABLE t2 AS SELECT distinct * FROM t1; drop table t1') If $ret <> $SQLITE_OK Then Exit (MsgBox(0, 'SQLITE ERROR', 'Create Final Table Failed')) ; retrieve entries ordered by column 1 desc within column 2 asc Local $ret, $arows, $irows, $icols _SQLite_GetTable2d(-1, 'select * from t2 order by c2, c1;', $arows, $irows, $icols) ;strip sort order control byte For $1 = 1 To UBound($arows) - 1 $arows[$1][0] = StringTrimLeft($arows[$1][0], 1) Next Return $arows EndFunc Func _fini() _SQLite_Shutdown() Exit EndFunc ;==>_fini