GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Sort::Key::Types(3) User Contributed Perl Documentation Sort::Key::Types(3)

  use Sort::Key::Types qw(register_type);
  register_type(Color => sub { $_->R, $_->G, $_->B }, qw(int, int, int));

  # you better
  # use Sort::Key::Register ...

The Sort::Key family of modules can be extended to support new key types using this module (or the more friendly Sort::Key::Register).

The following functions are provided:
Sort::Key::register_type($name, \&gensubkeys, @subkeystypes)
registers a new datatype named $name defining how to convert it to a multi-key.

&gensubkeys should convert the object of type $name passed on $_ to a list of values composing the multi-key.

@subkeystypes is the list of types for the generated multi-keys.

For instance:

  Sort::Key::Types::register_type
                 'Person',
                 sub { $_->surname,
                       $_->name,
                       $_->middlename },
                 qw(str str str);

  Sort::Key::Types::register_type
                 'Color',
                 sub { $_->R, $_->G, $_->B },
                 qw(int int int);
    

Once a datatype has been registered it can be used in the same way as types supported natively, even for defining new types, i.e.:

  Sort::Key::Types::register_type
                 'Family',
                 sub { $_->father, $_->mother },
                 qw(Person Person);
    

Sort::Key, Sort::Key::Merger, Sort::Key::Register.

Copyright (C) 2005-2007, 2014 by Salvador Fandiño, <sfandino@yahoo.com>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.

2014-04-29 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.