Stvad / CrowdAnki

Plugin for Anki SRS designed to facilitate cooperation on creation of notes and decks.
MIT License
520 stars 44 forks source link

Export sort method doesn't sort subdecks #188

Closed wyohm closed 1 year ago

wyohm commented 1 year ago

I was trying to export sorted by guid to make for minimal diffs (when notes are added by contributors) and wasn't seeing any change from the default output order. I tried various other sort methods (eventually including reverse order) and none had any effect. I finally tried exporting a deck which did not have subdecks (my original efforts were using a deck where all the notes were in subdecks) and the export sorting works as expected.

It may be sorting the subdecks themselves (order of the subdecks not the order of the notes within) by the "crowdanki_uuid" since I see them in sequence, but it's also the order that the subdecks are listed in Anki, so there's no change and I'm not sure where the order of the subdecks is coming from.

aplaice commented 1 year ago

Yes, you're right. The contents of subdecks currently aren't sorted at all. :/ I'll look into this!

The subdecks themselves are ("iteratively"*) sorted by their names.

* "iteratively"/recursively in the sense that if we have deck a with subdecks b1 and b2, of which b1 contains c1 and c2, while b2 contains c3 and c4, then you'll have:

{
  "name": "a"
  "children": [
    {
      "name": "b1",
      "children": [
        {
          "name": "c1",
          ...
        },
        {
          "name": "c2",
          ...
        },
      ],
      ...
    },
    {
      "name": "b2",
      "children": [
        {
          "name": "c3",
          ...
        },
        {
          "name": "c4",
          ...
        },
      ],
      ...
    }
  ],
  ...
}

Thanks!

wyohm commented 1 year ago

Thanks for explaining subdeck sorting!