Sign in Join
FPDoc Onlineexperiment

NaturalCompareText function

In unit StrUtils

Compare using natural sort.

Declaration

pascal
function NaturalCompareText(const S1: string; const S2: string)
: 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

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.