How one dev team optimized JavaScript data grid to sort one million rows fast
A development team behind a JavaScript data grid documented how they achieved sub-second sorting of one million browser-side rows without freezing the page. The key breakthrough was a decorate-sort-undecorate technique, where sort keys are computed once per row before sorting, rather than repeatedly inside the comparator during roughly 20 million comparisons. For text columns, they pre-ranked a dictionary of distinct strings using Intl.Collator once and then reduced subsequent text sorts to fast integer comparisons, bringing repeat sort time down to around 90 milliseconds. The team also uncovered a subtle bug where case variants like 'Berlin' and 'berlin' were assigned different ranks despite the collator treating them as equal, which silently broke multi-column sort ordering. They now publish both first-sort and repeat-sort benchmarks side by side, acknowledging that showing only the cached fast figure would be misleading.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in