-
Notifications
You must be signed in to change notification settings - Fork 134
Open
Labels
Description
We'd want to facilitate users sorting blocks according to their needs.
They easiest and most general way to do this would probably be to create a new abstract class SortBlocksMiddleware with the following properties:
- The abstract class should have just one unimplemented method, and it should have the signature
compare(block1, block2) -> int, following the standard convention that any returned value > 0 indicates that block2 should come anywhere after block1, any value <0 the opposit and a return value of 0 sais that any order of the two should be fine. - The docstring of the
comparemethod should list the standard conventions for such a method (the conditions above, but also that it's transitive, pure, ...) - Our own
SortBlocksByTypeAndKeyMiddlewareshould extend/implementSortBlocksMiddleware - The documentation should provide a simple MWE
Location of the code: https://github.com/sciunto-org/python-bibtexparser/blob/main/bibtexparser/middlewares/sorting_blocks.py
I am currently not working on this, so feel free to comment below if you want to take over.