in reply to Database Structure/Sorting/Displaying
Well, I'll just address your sorting question/issue--- you can sort on the catalogue number by dividing each one into 3 components: leading non-digits (if any), digits, trailing non-digits (if any) ... and then defining the sort routine to sort on these components. Here's an off the cuff Schwartzian Transform applied to the data:
#!/usr/bin/perl -w use strict; my @list = qw/715b E9 715a 614 715 C18 1 4 12a 12/; my @sorted = map{$_->[0]} sort{$a->[1] cmp $b->[1] || $a->[2] <=> $b->[2] || $a->[3] cmp $b->[3]} map{[$_,/(\D*)(\d+)(\D*)/]} @list; print join("\n", @sorted),"\n";
Knowing how to sort on catalogue numbers should relieve you of the need to use a special sort N field in the data. Having said that, you might also want to look into the DB_File dbm system which has a BTREE mode for keeping entries in sorted order (you can provide a comparison routine), and it has facilities for matching partial keys which can be used to code for retrieving ranges.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Database Structure/Sorting/Displaying
by Stamp_Guy (Monk) on Jul 04, 2001 at 23:41 UTC | |
by danger (Priest) on Jul 05, 2001 at 19:41 UTC |