Skip to content

Commit

Permalink
examples: list notes first when sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
marph91 committed Jan 1, 2025
1 parent 20e997f commit 18e07b9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions examples/note_tree_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,16 @@ def sub_tree_to_txt(item_tree, level=0):


def sort_item_tree(item_tree):
"""Sort all items based on their title."""
"""
Sort all items:
1. Notes before notebooks
2. Alphabetically by title
"""
def sort_function(item):
return isinstance(item[0], Notebook), item[0].title
return {
key: sort_item_tree(value) if isinstance(value, dict) else value
for key, value in sorted(item_tree.items(), key=lambda item: item[0].title)
for key, value in sorted(item_tree.items(), key=sort_function)
}


Expand Down

0 comments on commit 18e07b9

Please sign in to comment.