On Mon, 14 Feb 2022, James Richters via fpc-pascal wrote:

Is there a quick way to sort a stringlist on it's   .ValueFromIndex field
instead of it's   .Names field?


// Custom compare function
function CompareValues(List: TStringList; Index1, Index2: Integer): Integer;

begin
  Result:=CompareText(List.ValueFromIndex[Index1],List.ValueFromIndex[Index2])
end;

// Sort using custom compare function
Mylist.CustomSort(@CompareValues);

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to