Sort by any order

From JmPm

(Difference between revisions)
Jump to: navigation, search
(from old wiki)
m (Protected "Sort by any order": spam [edit=autoconfirmed:move=autoconfirmed])

Revision as of 12:42, 14 March 2007

@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:


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