1Sort::Key::Types(3)   User Contributed Perl Documentation  Sort::Key::Types(3)
2
3
4

Sort::Key::Types - handle Sort::Key data types

SYNOPSIS

7         use Sort::Key::Types qw(register_type);
8         register_type(Color => sub { $_->R, $_->G, $_->B }, qw(int, int, int));
9
10         # you better
11         # use Sort::Key::Register ...
12

DESCRIPTION

14       The Sort::Key family of modules can be extended to support new key
15       types using this module (or the more friendly Sort::Key::Register).
16
17   FUNCTIONS
18       The following functions are provided:
19
20       Sort::Key::register_type($name, \&gensubkeys, @subkeystypes)
21           registers a new datatype named $name defining how to convert it to
22           a multi-key.
23
24           &gensubkeys should convert the object of type $name passed on $_ to
25           a list of values composing the multi-key.
26
27           @subkeystypes is the list of types for the generated multi-keys.
28
29           For instance:
30
31             Sort::Key::Types::register_type
32                            'Person',
33                            sub { $_->surname,
34                                  $_->name,
35                                  $_->middlename },
36                            qw(str str str);
37
38             Sort::Key::Types::register_type
39                            'Color',
40                            sub { $_->R, $_->G, $_->B },
41                            qw(int int int);
42
43           Once a datatype has been registered it can be used in the same way
44           as types supported natively, even for defining new types, i.e.:
45
46             Sort::Key::Types::register_type
47                            'Family',
48                            sub { $_->father, $_->mother },
49                            qw(Person Person);
50

SEE ALSO

52       Sort::Key, Sort::Key::Merger, Sort::Key::Register.
53
55       Copyright (C) 2005-2007, 2014 by Salvador FandiƱo,
56       <sfandino@yahoo.com>.
57
58       This library is free software; you can redistribute it and/or modify it
59       under the same terms as Perl itself, either Perl version 5.8.4 or, at
60       your option, any later version of Perl 5 you may have available.
61
62
63
64perl v5.32.0                      2020-07-28               Sort::Key::Types(3)
Impressum