program Order_two_numerical_lists; {$APPTYPE CONSOLE} uses System.SysUtils, System.Generics.Defaults; type TArray = record class function LessOrEqual(first, second: TArray): Boolean; static; end; class function TArray.LessOrEqual(first, second: TArray): Boolean; begin if Length(first) = 0 then exit(true); if Length(second) = 0 then exit(false); var comp := TComparer.Default.Compare(first[0], second[0]); if comp = 0 then exit(LessOrEqual(copy(first, 1, length(first)), copy(second, 1, length(second)))); Result := comp < 0; end; begin writeln(TArray.LessOrEqual([1, 2, 3], [2, 3, 4])); writeln(TArray.LessOrEqual([2, 3, 4], [1, 2, 3])); writeln(TArray.LessOrEqual([1, 2], [1, 2, 3])); writeln(TArray.LessOrEqual([1, 2, 3], [1, 2])); writeln(TArray.LessOrEqual(['a', 'c', 'b'], ['a', 'b', 'b'])); writeln(TArray.LessOrEqual(['this', 'is', 'a', 'test'], ['this', 'is', 'not', 'a', 'test'])); readln; end.