We have a list of user objects like { name: 'Alice', age: 25 } fetched from an API. We need to display them in a table sorted by age ascending. How would you write the sort logic, and what's a common trap to avoid regarding the original array?
Imagine you have an array of product objects with a price property. If you just call .sort() without passing any arguments, what happens to prices like 9, 100, and 20? How do you fix that?
In our React app, we have a state array of transaction objects. A developer wrote const sorted = transactions.sort((a, b) => b.amount - a.amount) and passed it to a component, but the UI isn't re-rendering when the sort order changes. What's going on here, and how would you fix it?
We are building a global e-commerce site. We need to sort products alphabetically by their localized title (which can contain accents or non-English characters). How would you implement this to ensure it works correctly across different languages?
We have a dashboard displaying a real-time feed of up to 50,000 log objects. Users can sort by timestamp, severity, or service name. Re-sorting the entire array on every single WebSocket update is causing frame drops. How would you optimize this sorting behavior at the component level?
You need to design a reusable utility function for a team's shared library that can sort an array of complex, deeply nested objects by dynamic keys (e.g., 'author.profile.lastName'). How would you design the API for this utility, and how would you handle missing or malformed paths safely?
Our platform handles massive datasets in the browser (e.g., client-side data grids with 100k+ rows). We are seeing main-thread blocking during complex multi-column sorts. How would you architect a non-blocking sorting solution, and what are the architectural trade-offs of moving this work to a Web Worker versus doing it on the backend?
We are migrating a legacy codebase where different teams have implemented their own sorting helpers, leading to inconsistent sorting behavior (some stable, some unstable, some mutating state). How would you design and roll out a standardized sorting strategy and linting/tooling rules across 20+ engineering teams without breaking existing features?