As of October, 2016, Embarcadero is offering a free release
of Delphi (Delphi
10.1 Berlin Starter Edition ). There
are a few restrictions, but it is a welcome step toward making
more programmers aware of the joys of Delphi. They do say
"Offer may be withdrawn at any time", so don't delay if you want
to check it out. Please use the
link to let me know if the link stops working.
Support DFF - Shop
If you shop at Amazon anyway, consider using
this link. We receive a few cents from each purchase.
Support DFF - Donate
If you benefit from the website, in terms of
knowledge, entertainment value, or something otherwise useful,
consider making a donation via PayPal to help defray the
costs. (No PayPal account necessary to donate via credit
card.) Transaction is secure.
e-mail with your comments about this program (or anything else).
||Custom "Numeric" Sort
Here's a program illustrating the use of the "Custom Sort" feature of the
Delphi TStringList class. The default TStringList "Sort" method arranges the
strings in lexicographic (dictionary) order. The "CustomSort" method passes two
index pointers to a user defined function and expects the user function
to return one of three values: -1, +1, or 0 indicating that the first string is
"less than", "greater than" or "equal to" the second string.
In this demonstration program, the requirement is to sort a set of file names
containing embedded numeric information into sequence accounting for the numeric
values. For example, "A100A.xxx" will come before "A11.xxx" in a standard sort
but after if numbers are treated as numeric values.
The user function in this case separates each pair of strings into 3 pieces: an
alpha prefix, a number, and an alpha suffix. The alphabetic parts are converted
to upper case to make the comparison case insensitive. The pieces are compared
in sequence with a non-equal result after each piece
determining the returned result.
|Created: September 8, 2013
February 18, 2016