Unit 'StrUtils' Package
[Overview][Resource strings][Constants][Types][Procedures and functions][Index] [#rtl]

NaturalCompareText

Compare using natural sort.

Declaration

Source position: strutils.pp line 90

function NaturalCompareText(

  const S1: string;

  const S2: string

):Integer;

function NaturalCompareText(

  const Str1: string;

  const Str2: string;

  const ADecSeparator: AnsiChar;

  const AThousandSeparator: AnsiChar

):Integer;

Description

NaturalCompareText will compare 2 strings and return one of the following values:

-1
If S1 comes before S2
0
If S1 equals S2
1
If S1 comes after S2

When S1 and S2 are integer or floating point values, the actual values are compared. Thus '12' will come after '2'. If either of the values is not a valid integer or floating point values, the strings are compared case insensitively as texts using CompareText

A decimal separator and thousands separator can optionally be specified in ADecSeparator, AThousandSeparator. If none are specified, the defaults from the system unit will be used.

See also

CompareText


Documentation generated on: Dec 24 2024