We have callnumbers like 1 A 1, 10 A 10, 100 A 100 and 1000 A 100. Alphabetically sorting those does not work (100 A 100 < 2 A 2) This proposal includes adding a syspref to define callnumber formats that also specify the desired length when zero-padding cn_sort. This would be active when using C4::ClassSortRoutine::Generic. In the above case we would like to sort them with 0001 A 001, 0010 A 010, 0100 A 100 and 1000 A 100. So the first digit block has length 4, the second block 3.
I'm interested in this. I'm having a similar problem with the generic classification source. I have one library where it would be nice to detect digits and zero pad them to N places to have a more intelligent sort rather than lexicographic sorting.
Are you likely to work on this, Marcel?
(In reply to David Cook from comment #2) > Are you likely to work on this, Marcel? Yeah see Assignee/status.
Removing 'cruft' from the callnumber should be done after zero padding: | RCE TEST 1.33.45 Mid (1) | RCE_TEST_001033045_MID_1 | We want 1.33.45 not to be interpreted as one digit group (13345) but as three digit groups since the dot serves as delimiter.
Created attachment 193984 [details] [review] Bug 41932: Adjust generic class sort to allow zero-padding Test plan: Run t/ClassSortRoutine_Generic.t Add a few callnumber formats in ClassSortGenericFormats like: ^A:1,3;1,2;;^B:1,2 In words: callnumber starts with A, 1 or more digits (pad to 3), then 1 or more digits (pad to 2). Or callnumber starts with B, one or more digits (pad to 2). Enable generic call number sorting rules in Classification configuration. Now save a few items with callnumbers: 1 A 1, 10 A 2, B2, B11. Check if cn_sort now matches: 001_A_01, 100_A_02, B02, B11. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
(In reply to David Cook from comment #2) > Are you likely to work on this, Marcel? Here is an impression of where I am at now. This comes from 24.11. I need to polish a bit still: add a preference and description, add a db revision, test on main etc. But it is almost ready. Chose for a preference approach above plugin approach here. Many libraries may want to selectively zero pad with multiple schemes. This is possible by an intelligent use of the pref introduced here working with a filter regex and a list of minimum length versus minimum sort length values.
(In reply to Marcel de Rooy from comment #6) > (In reply to David Cook from comment #2) > > Are you likely to work on this, Marcel? > > Here is an impression of where I am at now. This comes from 24.11. I need to > polish a bit still: add a preference and description, add a db revision, > test on main etc. But it is almost ready. > > Chose for a preference approach above plugin approach here. Many libraries > may want to selectively zero pad with multiple schemes. This is possible by > an intelligent use of the pref introduced here working with a filter regex > and a list of minimum length versus minimum sort length values. Thanks for taking this on. I wanted to do it for one library but couldn't get sponsorship for it. I had thought about doing a totally separate name for it rather than generic though just to have a cleaner separation. Are you thinking of adding the syspref inside C4/ClassSortRoutine/Generic.pm? Or would it be in the caller of get_class_sort_key? Probably cleaner to do the latter.
I suppose whether we used a different name than Generic or used a syspref, there will be a little bit of work to do in applying it to existing items. I mean a touch_all_items.pl will do the trick but I suppose we don't want to alter existing behaviour without an option (like a syspref or a different name). Anyway, look forward to seeing more. Happy to QA this one.
(In reply to David Cook from comment #7) > Are you thinking of adding the syspref inside > C4/ClassSortRoutine/Generic.pm? Or would it be in the caller of > get_class_sort_key? Probably cleaner to do the latter. Since the syspref is so tight to the routine that does the work, I think that the current handling within Generic is cleaner.