Sort by any order

From JmPm

Revision as of 17:34, 18 March 2007 by Amire80 (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search
@afields is an array of subfields with the subfield name 

my %cpr = (a => 1, d => 2, c => 3, l => 4;)

@afields = sort afld @afields;

sub afld{ $cpr{substr($a,2,1)} <=> $cpr{substr($b,2,1)}; };


# Hey folks - is this some ExLibris - specific stuff? It's worth to mention this. Eitan

Eitan, this is indeed ExLibris/ALEPH stuff. For the others, here is an explanation:

The input is $$cCCCCCCC$$aAAAAAAAAa$$lLLLLLL$$dDDDDDD

Where the $$ is a delimiter and the letter after it is the code of the sub-field.

The idea is to sort the sub-fields, but not nessecarily in alphabetical order.

In the example above, the order should be a,d,c,l.

Personal tools