Reported September 2024
TikToksorting

Sort Social Media Feeds

Reported by candidates from TikTok's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live TikTok OA. Under 2s to a working solution.
Founder's read

TikTok's September OA asked candidates to sort social media feeds, a straightforward sorting problem that tests whether you can implement custom sort logic under time pressure. You're not building a recommendation engine here. The ask is simpler: given feed data, apply a comparator and return the sorted result. It's the kind of problem where the trick isn't the algorithm itself, it's not overthinking the requirements. StealthCoder can handle this if you blank on comparator syntax, but the pattern is solid ground for most engineers.

Pattern and pitfall

The core pattern is sorting with a custom comparator. You'll likely receive feed items (posts, videos, users) with multiple fields like timestamp, engagement count, or priority score. The trap is trying to sort by multiple criteria at once without thinking through the tiebreaker logic. Most candidates write the sort correctly but fail edge cases: ties, null values, or reverse order. The algorithm itself is O(n log n) and doesn't need dynamic programming or fancy data structures. If you hit a wall on comparator syntax during the live OA, StealthCoder reads the problem statement and surfaces the right approach immediately, letting you code with confidence instead of second-guessing the sort order.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Sort Social Media Feeds cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as sort the matrix diagonally. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass TikTok's OA.

TikTok reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Sort Social Media Feeds FAQ

Is this problem asking me to optimize the sort, or just implement it correctly?+

Just implement it correctly. TikTok wants to see clean comparator logic and proper handling of edge cases. No need for fancy heap tricks or custom data structures. O(n log n) is the expected baseline.

What's the most common mistake candidates make on feed sorting problems?+

Forgetting the tiebreaker. When two feed items have the same primary sort key, the comparator breaks. Write your comparator to handle ties explicitly, or the test cases fail silently.

Can I solve this in Python with sorted() and a lambda, or do I need a formal Comparator class?+

Python's sorted() with a lambda or key function is totally fine and faster to write. Java and C++ may need a Comparator interface. Pick the syntax you're fastest in. The logic matters, not the wrapper.

Should I expect multiple sort criteria, or just one field?+

Expect at least two. Primary sort by timestamp or score, secondary sort by id or user to break ties. Read the problem carefully. The expected output hints at the sort order.

How do I prepare for this in 48 hours if I'm rusty on comparators?+

Write three sorting problems with custom comparators in your language of choice. Focus on tiebreaker logic and reverse sort. Muscle memory matters more than theory here.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with TikTok.

OA at TikTok?
Invisible during screen share
Get it