Skip to content

Bug: Repositories with identical star counts render in non-deterministic, flickering order #613

Description

@pradeep0153

Description

A logic bug exists in the primary <RepositoryGrid /> sorting algorithm. The grid is designed to sort a user's repositories by total stars (descending). However, if a user has multiple repositories with the exact same star count (e.g., three repos with 0 stars, or two repos with 5 stars), the Array.prototype.sort() algorithm fails to implement a deterministic secondary sorting parameter. This causes the order of those specific repositories to flicker and change randomly every time the page is refreshed or a new batch is paginated.

Proposed Solution

  • Audit the client-side (or server-side) sorting utility function applied to the repository array.
  • Implement a robust, multi-tier sorting heuristic.
  • The primary sort parameter must remain stargazerCount (descending).
  • Inject a strict secondary sort parameter: if repoA.stargazerCount === repoB.stargazerCount, fallback to sorting by updatedAt (most recently pushed to first).
  • This mathematically guarantees a 100% deterministic, stable rendering order across all sessions, completely eliminating the UI flicker and ensuring the user's most recently active projects are always prioritized in tie-breaker scenarios.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions