Ordering non-standard call numbers

I have been approached by a colleague about the ordering of the call numbers which seems to have changed recently. They use non-standard call numbers in the form

M 1
M 2
M 10 a
M 11
M 100 b

But currently the ordering in Zotero is not respecting the increasing numbers in the middle. It is output in the wrong (alphabethical) order like: M 1, M 10 a, M 100 b, M 11, M 2.

This is not any standard call number like LC or Dewey, but some house-made schema for the call numbers.

Could this probably fixed by just expanding the last else case code in the compareCallNumbers function? I mean in line 1070 (https://github.com/zotero/utilities/blob/master/utilities_item.js#L1070) replace

return (fieldA > fieldB) ? 1 : (fieldA < fieldB) ? -1 : 0;

with something like

return Zotero.localeCompare(fieldA, fieldB);


Note: My tests with Int.Collator (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator) showed that this could work, but I haven't tested (and can't) that this code within Zotero would work and lead to the desired output. Any alternative approach for this is also appreciated.
  • edited September 7, 2023
  • @zuphilip has certainly earned the right to ping people, but I'm not the one who would be working on this, and any fix anytime soon would probably need to be a contributed patch. This code is also in a separate repo that only requires Node and has test coverage, so it should be easy to work on if someone wants to do so.
  • Okay, thank you for the reaction, and sorry, about the ping (I thought it could be the right thing to not forget about it). I read from your answer, that this change might be fine to try and (at least) there is no ovious reason why not to do it. Thank you for the further details (encouragements) about the practical implementation. I need to see whether I can work on this myself.
  • Thank you zuphilip for your post in the forum and your work on github.

    The new sorting works.

    But only as long as there are no spaces in the sorting.


    M11, M12, M110 .....

    M 11, M 110, M 12 ....

    Is there a way to ignore spaces or handle them differently?
Sign In or Register to comment.