ActiveState!

ActivePerl Documentation
Table of Contents

(Usage Statistics)
(about this ver)


* Getting Started
    * Welcome To ActivePerl
    * Release Notes
    * Readme
    * ActivePerl Change Log
* Install Notes
    * Linux
    * Solaris
    * Windows
* ActivePerl Components
    * Overview
    * PPM
    * Windows Specifics
       * OLE Browser
       * PerlScript
       * Perl for ISAPI
       * PerlEZ
* ActivePerl FAQ
    * Introduction
    * Availability & Install
    * Using PPM
    * Docs & Support
    * Windows Specifics
       * Perl for ISAPI
       * Windows 9X/NT/2000
       * Quirks
       * Web Server Config
       * Web programming
       * Programming
       * Modules & Samples
       * Embedding & Extending
       * Using OLE with Perl
* Windows Scripting
    * Active Server Pages
    * Windows Script Host
    * Windows Script Components

Core Perl Documentation


* perl
* perlfaq
* perltoc
* perlbook

* perlsyn
* perldata
* perlop
* perlreftut
* perldsc
* perllol

* perllexwarn
* perldebug

* perlrun
* perlfunc
* perlopentut
* perlvar
* perlsub
* perlmod
* perlpod

* perlstyle
* perlmodlib
* perlmodinstall
* perltrap
* perlport
* perlsec

* perlref
* perlre
* perlform
* perllocale
* perlunicode

* perlboot
* perltoot
* perltootc
* perlobj
* perlbot
* perltie

* perlipc
* perlnumber
* perlfork
* perlthrtut

* perldiag
* perlfaq1
* perlfaq2
* perlfaq3
* perlfaq4
* perlfaq5
* perlfaq6
* perlfaq7
* perlfaq8
* perlfaq9

* perlcompile

* perlembed
* perlxstut
* perlxs
* perlguts
* perlcall
* perlfilter
* perldbmfilter
* perlapi
* perlintern
* perlapio
* perltodo
* perlhack

* perlhist
* perldelta
* perl5005delta
* perl5004delta

* perlamiga
* perlcygwin
* perldos
* perlhpux
* perlmachten
* perlos2
* perlos390
* perlvms
* perlwin32

Pragmas


* attributes
* attrs
* autouse
* base
* blib
* bytes
* charnames
* constant
* diagnostics
* fields
* filetest
* integer
* less
* lib
* locale
* lwpcook
* open
* ops
* overload
* perllocal
* re
* sigtrap
* strict
* subs
* utf8
* vars
* warnings

Libraries


* ActivePerl
    * DocTools
        * TOC
            * RDF
* AnyDBM_File
* Archive
    * Tar
* AutoLoader
* AutoSplit
* B
    * Asmdata
    * Assembler
    * Bblock
    * Bytecode
    * C
    * CC
    * Debug
    * Deparse
    * Disassembler
    * Lint
    * Showlex
    * Stackobj
    * Terse
    * Xref
* Benchmark
* Bundle
    * LWP
* ByteLoader
* Carp
    * Heavy
* CGI
    * Apache
    * Carp
    * Cookie
    * Fast
    * Pretty
    * Push
    * Switch
* Class
    * Struct
* Compress
    * Zlib
* Config
* CPAN
    * FirstTime
    * Nox
* Cwd
* Data
    * Dumper
* DB
* Devel
    * DProf
    * Peek
    * SelfStubber
* Digest
    * HMAC
    * HMAC_MD5
    * HMAC_SHA1
    * MD2
    * MD5
    * SHA1
* DirHandle
* Dumpvalue
* DynaLoader
* English
* Env
* Errno
* Exporter
    * Heavy
* ExtUtils
    * Command
    * Embed
    * Install
    * Installed
    * Liblist
    * MakeMaker
    * Manifest
    * Miniperl
    * Mkbootstrap
    * Mksymlists
    * MM_Cygwin
    * MM_OS2
    * MM_Unix
    * MM_VMS
    * MM_Win32
    * Packlist
    * testlib
* Fatal
* Fcntl
* File
    * Basename
    * CheckTree
    * Compare
    * Copy
    * CounterFile
    * DosGlob
    * Find
    * Glob
    * Listing
    * Path
    * Spec
        * Functions
        * Mac
        * OS2
        * Unix
        * VMS
        * Win32
    * stat
* FileCache
* FileHandle
* FindBin
* Font
    * AFM
* Getopt
    * Long
    * Std
* HTML
    * AsSubs
    * Element
    * Entities
    * Filter
    * Form
    * FormatPS
    * Formatter
    * FormatText
    * HeadParser
    * LinkExtor
    * Parse
    * Parser
    * TokeParser
    * TreeBuilder
* HTTP
    * Cookies
    * Daemon
    * Date
    * Headers
        * Util
    * Message
    * Negotiate
    * Request
        * Common
    * Response
    * Status
* I18N
    * Collate
* IO
    * Dir
    * File
    * Handle
    * Pipe
    * Poll
    * Seekable
    * Select
    * Socket
        * INET
        * UNIX
* IPC
    * Msg
    * Open2
    * Open3
    * Semaphore
    * SysV
* LWP
    * Debug
    * MediaTypes
    * MemberMixin
    * Protocol
    * RobotUA
    * Simple
    * UserAgent
* Math
    * BigFloat
    * BigInt
    * Complex
    * Trig
* MD5
* MIME
    * Base64
    * QuotedPrint
* NDBM_File
* Net
    * Cmd
    * Config
    * Domain
    * DummyInetd
    * FTP
    * hostent
    * libnetFAQ
    * netent
    * Netrc
    * NNTP
    * PH
    * Ping
    * POP3
    * protoent
    * servent
    * SMTP
    * SNPP
    * Time
* O
* ODBM_File
* Opcode
* Pod
    * Checker
    * Find
    * Html
    * InputObjects
    * Man
    * Parser
    * ParseUtils
    * Plainer
    * Select
    * Text
        * Color
        * Termcap
    * Usage
* POSIX
* PPM
    * SOAPClient
    * SOAPServer
* Safe
* SDBM_File
* Search
    * Dict
* SelectSaver
* SelfLoader
* SHA
* Shell
* SOAP
    * Defs
    * Envelope
    * EnvelopeMaker
    * GenericHashSerializer
    * GenericInputStream
    * GenericScalarSerializer
    * Lite
    * OutputStream
    * Packager
    * Parser
    * Transport
        * HTTP
            * Apache
            * CGI
            * Client
            * Server
        * LOCAL
        * MAILTO
        * POP3
        * TCP
    * TypeMapper
* Socket
* Symbol
* Sys
    * Hostname
    * Syslog
* Term
    * ANSIColor
    * Cap
    * Complete
    * ReadLine
* Test
    * Harness
* Text
    * Abbrev
    * ParseWords
    * Soundex
    * Tabs
    * Wrap
* Thread
    * Queue
    * Semaphore
    * Signal
    * Specific
* Tie
    * Array
    * Handle
    * Hash
    * RefHash
    * Scalar
    * SubstrHash
* Time
    * gmtime
    * Local
    * localtime
    * tm
* UDDI
    * Lite
* UNIVERSAL
* URI
    * data
    * Escape
    * file
    * Heuristic
    * ldap
    * URL
    * WithBase
* User
    * grent
    * pwent
* Win32
    * AuthenticateUser
    * ChangeNotify
    * Clipboard
    * Console
    * Event
    * EventLog
    * File
    * FileSecurity
    * Internet
    * IPC
    * Mutex
    * NetAdmin
    * NetResource
    * ODBC
    * OLE
        * Const
        * Enum
        * NEWS
        * NLS
        * TPJ
        * Variant
    * PerfLib
    * Pipe
    * Process
    * Registry
    * Semaphore
    * Service
    * Sound
    * TieRegistry
* Win32API
    * File
    * Net
    * Registry
* WWW
    * RobotRules
        * AnyDBM_File
* XML
    * Element
    * Parser
        * Expat
    * PPD
    * PPMConfig
    * ValidatingElement
* XSLoader

 Sort::PolySort -- general rules-based sorting of lists


NAME

        Sort::PolySort -- general rules-based sorting of lists


SUPPORTED PLATFORMS

  • Linux
  • Solaris
  • Windows
This module is not included with the standard ActivePerl distribution. It is available as a separate download using PPM.

SYNOPSIS

        use Sort::PolySort;
        $s=new Sort::PolySort;                  # defaults to 'name'
        @people=('John Doe','Jane Doll','John Quasimodo Doe');
        print join(", ",$s->sort(@people),"\n";

        use Sort::PolySort;
        $s=new Sort::PolySort('dateus');        # sets internal
        @dates=$s->sort(@dates);                # uses internal
        $s->by('email');                        # sets internal
        @names=$s->sortby('name',@names);       # overrides internal
        @emails=$s->sort(@emails);              # internal is still 'email'


DESCRIPTION

This module provides methods to sort a list of strings based on parsing the strings according to a configurable set of specifications.

METHODS

The following methods are available:

new
Creates a new polysort object. Takes optional arguement of initial named spec set (defaults to name).

by
Configures for the named set of sorting specs. Arguement is name of spec set.

sort
Sorts by the previously-set (by new or by) specs. Arguement is a list of items to sort. Returns the sorted list, leaving the original unchanged.

sortby
Sorts by the given (named) set of specs. The specs are only changed for this particular sort, so future calls to sort will use whatever specs were in effect before the sortby call. First arguement is name of spec set, second arguement is a list of items to sort. Returns the sorted list, leaving the original unchanged.

get
Returns an associative array of the current sort specs. See NOTES.

set
Sets the current sort specs to the given associative array. Specs not appearing in the passed array retain their previous values, so this method can be used along with get to keep state during a subroutine call or to alter particular specs to get new sorting results. Arguement is an associative array. See NOTES.

Specs

The following specifications are local to each Sort::PolySort object:

GLOBTOP
Lump last two levels together?

LEVELS
Number of levels to consider (0=all)

R2L
Count fields right to left?

NUMERIC
Do numerical sort?

CASE
Do case-sensitive sort?

DELIM1
Primary element delimiter (must not be null).

DELIM2
Secondary element delimiter (can be null).

Parsing Scheme

The following order is followed to determine the keys used to sort the given array:

  1. DELIM2 (if given)

    Remove up to leftmost (rightmost if R2L is true) occurance of DELIM2 (will be brought back later).

  2. DELIM1

    Split remainder at all occurances of DELIM1.

  3. GLOBTOP (if true)

    Rejoin left (right if R2L is true) 2 elements (always joined left-to-right, regardless of R2L).

  4. R2L (if true)

    Reverse list of elements.

  5. LEVELS

    Store first LEVELS (all if =0) elements (last 2 considered as a single element if GLOBTOP is true).

  6. DELIM2 (if true)

    Store string from left of DELIM2 as next element.

  7. LEVELS (unless 0)

    Rejoin remaining elements (in original order, regardless of R2L) and store as next element.

Named Specs

The following (case-sensitive) names are used by new, by and sortby to represent pre-defined sets of specs:

datebr
by European (dd/mm/yy) date

dateus
by US-style (mm/dd/yy) date

email
by user for each machine (all parts of FQDN)

email2
by user for each top-level domain (last 2 atoms)

emaild
by user for each domain-name (next-to-last atom)

ip
by numerical (aaa.bbb.ccc.ddd) ip address

name
by last name/first name/middle name or initials


ERRORS

The following errors may occur:

No specname given
by or sortby wasn't passed a specname.

Never heard of specname ``foo''
new, by, or sortby was passed a name that was not in the list of known specnames.


NOTES

The whole parsing method is pretty perverse, but honestly was the first thing that came to mind. It works, but is not very fast or extensible. Enough interested folks mailed me that I wanted to get this out now, but it's dyin' for a rewrite. So this is just a beta. The main interface will remain the same, but the parser will be rewritten and the spec variables changed. Accessor methods will change as a result (using %s=$s-get; ... ;$s->set(%s) will probably still work to save state, though). And accessor methods wll be added so that new names spec sets can be added at runtime or known ones modified. And new named spec sets will be added. And on and on and on...


AUTHOR

Daniel Macks <dmacks@netspace.org>


COPYRIGHT

Copyright (c) 1996 by Daniel Macks. All rights reserved. This module is free software; you may redistribute it and/or modify it under the same terms as Perl itself.

 Sort::PolySort -- general rules-based sorting of lists