The following module was proposed for inclusion in the Module List:
modid: Sort::ArrayOfArrays
DSLIP: RdpOp
description: sort an array of arrays by arbitrary methods
userid: EARL (Earl Cahill)
chapterid: 6 (Data_Type_Utilities)
communities:
similar:
none I've seen for an array or arrays
rationale:
Was written to help make html pages displaying data, where column
headers could be clicked to sort on the respective columns. Headers
can be clicked twice to reverse the sort. A couple of simple
conventions are used.
1. To sort on column 1, column 4 reversed and column 0 reversed,
simple pass the structure, the string '1,-4,-0' and any special sort
methods. Returned is the sorted structure.
2. For each column, a different sort method may be used. The
default is 'aa', and I try to intelligently figure out if I should
switch to 'na' on the fly. A code ref may also be passed for each
column for a special sort, though there are a couple of tricks that
circumvent the need for passing a code ref.
'na' - numerical sort ascending, 'nd' - numerical sort descending,
'aa' - ascii sort ascending, 'ad' - ascii sort descending, 'ra' -
regex sort ascending, 'rd' - regex sort descending, 'la' - link sort
ascending, 'ld' - link sort descending,
For the regex sort, a regex is passed, with parens around the chunk
to sort on. For example, I needed to sort on a column with either
the line a script was on (85), or a range of lines (23 to 72). The
regex I passed for the respective column was /^(\d+)/, which would
get the number that started the cell and sort accordingly.
The link sorts are just wrappers around the regex sort with the
regex being @^<a\s+href.+?>(.+?)</a>@.
Made doing "ORDER BY" functionality for some sql stuff I may later
open source near trivial. Will be used for soon to be released
Data::html2results and Data::results2html if I can ever figure out
where to put them. Descriptions of these modules are here
http://groups.google.com/groups?q=%22earl+cahill%22&hl=en&scoring=d&rnum=1&selm=2faf2bb9.0110171820.2132b0cc%40posting.google.com
if you have ideas for a good namespace suggestion, I would like to
hear it. The Data maintainer thinks they belong somewhere else,
though I don't really know where.
Module is very easy to use, and I think very useful.
Thanks, Earl
enteredby: EARL (Earl Cahill)
enteredon: Sat Nov 10 22:11:08 2001 GMT
The resulting entry would be:
Sort::
::ArrayOfArrays RdpOp sort an array of arrays by arbitrary methods EARL
Thanks for registering,
The Pause Team
PS: The following links are only valid for module list maintainers:
Registration form with editing capabilities:
https://pause.perl.org/pause/authenquery?ACTION=add_mod&USERID=51200000_7ac511ba440d9875&SUBMIT_pause99_add_mod_preview=1
Immediate (one click) registration:
https://pause.perl.org/pause/authenquery?ACTION=add_mod&USERID=51200000_7ac511ba440d9875&SUBMIT_pause99_add_mod_insertit=1