Generate Fractional Rank Keys for Drag and Drop Task Ordering

Last updated: November 29, 2026

Quick Overview

Users drag tasks to reorder them in lists and board columns. Implement a function that, given the rank keys of the two neighbors, returns a new string key that sorts strictly between them, so a move updates only one row.

Asana
Software Engineering Fundamentals
Software Engineer
Asana
November 29, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Hard

0

0

0 solved


Users drag tasks to reorder them in lists and board columns. Implement a function that, given the rank keys of the two neighbors, returns a new string key that sorts strictly between them, so a move updates only one row.

Manual ordering is everywhere in Asana (list view, board columns, My Tasks sections) and it must stay consistent while many people drag at once. The interviewer checks whether you avoid renumbering whole lists inside a transaction, can reason about string ordering precisely, and know the costs of the approach.

What the Interviewer Expects
  • Rejects integer positions that force rewriting many rows per move
  • Represents positions as base-N fractions encoded as strings that sort lexicographically
  • Implements a correct midpoint, including the 'no room at this digit' case
  • States the no-trailing-zero invariant that guarantees a gap always exists
  • Discusses key growth and background rebalancing
Key Topics to Cover
fractional indexing
lexicographic ordering
transactions
drag and drop
rebalancing
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • How do you handle two users inserting between the same neighbors at the same moment?
  • How would you rebalance keys when they get long, and is it safe while users drag?
  • What index supports reading a column in order?
  • How does this compare with a linked list of next pointers?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

Keys are strings compared with plain byte order (what the database index uses). rank_between(None, None) starts a list; either side may be None at the ends. The result must sort strictly between nei...

High-Level Design

Treat each key as a fraction in (0, 1) written in base 62 with digits ordered as in ASCII. Walk the common prefix, then pick a digit halfway between the first differing digits. If they are adjacent, e...


Submit Your Answer
Markdown supported