Skip to content

Document how to use in practice #3

@nirvdrum

Description

@nirvdrum

I've watched the LexoRank video linked from the README, but I couldn't work out from either the video or the README how to best use the library. When reordering an item, calculating the new rank seems pretty straightforward. But it's not clear to me how to get going with a brand new list.

As far as I can tell, you want to do something like:

const firstItem = LexoRank.middle();
const secondItem = firstItem.genNext();
const thirdItem = secondItem.genNext();

But, that "wastes" half of the available rankings for the extremely unlikely event where the entire list gets reversed. But, the first Item can't be LexoRank.min() either, or you'd never be able to put something before it. I guess it could be something like LexoRank.min().between(LexoRank.middle()) or maybe LexoRank.min().genNext(). Maybe there isn't a right answer for this. But, any guidance the document could provide would be much appreciated.

In my particular case, I append items to a list by default and the user might opt to re-order the list. I expect reorderings to be relatively small and infrequent, so my primary concern would be exhausting the default space by cutting it in half each time a new item is appended.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions