PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Bobyard

Implement comment sorting and nesting

Last updated: Apr 22, 2026

Quick Overview

This question evaluates skills in frontend data handling and UI behavior, including implementing sortable lists, maintaining user-selected sort field and direction across refreshes, constructing nested comment trees from flat parentId references, and filtering content while preserving descendant visibility.

  • medium
  • Bobyard
  • Coding & Algorithms
  • Software Engineer

Implement comment sorting and nesting

Company: Bobyard

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given mock comment data on the frontend. Each comment has: - `id`: unique comment ID - `userId`: author ID - `timestamp`: creation time - `content`: comment text - `parentId`: nullable parent comment ID Implement the frontend behavior for a comment UI: 1. Display comments sorted by either `timestamp` or `userId`. 2. Support both ascending and descending order. 3. Preserve the user's selected sort field and sort direction after a page refresh. 4. Build nested comments from the flat input using `parentId` only; do not change the backend. 5. Add a text filter on `content` so that only comments matching the filter and all of their descendants are shown. Unrelated branches must be hidden. You may assume the data is provided locally as mock data.

Quick Answer: This question evaluates skills in frontend data handling and UI behavior, including implementing sortable lists, maintaining user-selected sort field and direction across refreshes, constructing nested comment trees from flat parentId references, and filtering content while preserving descendant visibility.

Bobyard logo
Bobyard
Apr 9, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
2
0

You are given mock comment data on the frontend. Each comment has:

  • id : unique comment ID
  • userId : author ID
  • timestamp : creation time
  • content : comment text
  • parentId : nullable parent comment ID

Implement the frontend behavior for a comment UI:

  1. Display comments sorted by either timestamp or userId .
  2. Support both ascending and descending order.
  3. Preserve the user's selected sort field and sort direction after a page refresh.
  4. Build nested comments from the flat input using parentId only; do not change the backend.
  5. Add a text filter on content so that only comments matching the filter and all of their descendants are shown. Unrelated branches must be hidden.

You may assume the data is provided locally as mock data.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Bobyard•More Software Engineer•Bobyard Software Engineer•Bobyard Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.