[fpc-pascal] Sorting a Stringlist on ValueFromIndex
    Michael Van Canneyt 
    michael at freepascal.org
       
    Tue Feb 15 08:05:36 CET 2022
    
    
  
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.
    
    
More information about the fpc-pascal
mailing list