Sort::Maker is a simple way to make efficient sort subs.
use Sort::Maker ;
my $sorter = make_sorter( ... ) ;
This module has two main goals: to make it easy to create correct sort functions, and to make it simple to select the optimum sorting algorithm for the number of items to be sorted. Sort::Maker generates complete sort subroutines in one of four styles, plain, orcish manouver, Schwartzian Transform and the Guttman-Rosler Transform. You can also get the source for a sort sub you create via the sorter_source call.
The sub make_sorter is exported by Sort::Maker. It makes a sort sub and returns a reference to it. You describe how you want it to sort its input by passing general options and key descriptions to make_sorter.
Arguments to make_sorter
There are two types of arguments, boolean and value. Boolean arguments can be set just with the option name and can optionally be followed by '1'. You can easily set multiple boolean general arguments with qw(). Value arguments must have a following value. Arguments can appear in any order but the key descriptions (see below) must appear in their sort order. The code examples below show various ways to set the various arguments.
Arguments fall into four categories: selecting the style of the sort, key descriptions, setting defaults for key description attributes, and setting general flags and values. The following sections will describe the categories and their associated arguments.
The style of the sort to be made is selected by setting one of the following Boolean arguments. Only one may be set otherwise an error is reported (see below for error handling). Also see below for detailed descriptions of the supported sort styles.
# Make a plain sorter
my $plain_sorter = make_sorter( qw( plain ) ... ) ;
# Make an orcish manouevre sorter
my $orcish_sorter = make_sorter( orcish => 1 ... ) ;
# Make a Schwartzian Transform sorter
my $st_sorter = make_sorter( 'ST', 1, ... ) ;
# Make a GRT sort
my $GRT = make_sorter( 'GRT', ... ) ;
Key Attribute Defaults
The following arguments set defaults for the all of the keys' attributes. These default values can be overridden in any individual key. Only one of the attributes in each of the groups below can be set as defaults or for any given key. If more than one attribute in each group is set, then make_sorter will return an error. The attribute that is the default for each group is marked. See below for details on key attributes.
These arguments set general options that apply to how the generated sorter interacts with the outside world.