Sort TSTringList Names property as integers instead of strings

I have a large text data file where each line looks like

10005=08/18/09,No BS,25094,wrg1

and the data is out of order (i.e. the number in front of the equal sign)

I load this file into a StringList as Value pairs. The TStringList sort function, of course, is not because numbers are strings, not integers.

How can I tidy them up before loading them into a TStringList?

Is there a quick function in which I execute a file that returns TStrings that I can assign a TStringList?

Thankx

0
source share
1 answer
function StrCmpLogicalW(sz1, sz2: PWideChar): Integer; stdcall;
  external 'shlwapi.dll' name 'StrCmpLogicalW';

function MyCompare(List: TStringList; Index1, Index2: Integer): Integer;
begin
  Result := StrCmpLogicalW(PWideChar(List[Index1]), PWideChar(List[Index2]));
end;

Using:

  StringList.CustomSort(MyCompare);
+4
source

Source: https://habr.com/ru/post/1534652/


All Articles