react-bootstrap-table2
react-bootstrap-table2 copied to clipboard
Optimized string column sort (comparator + splitNested)
I've started experiencing really bad delay when changing page in my table whenever sorting by a string value column. I found the splitNested function to be the culprit. See 2 perf screenshots below
![]() |
![]() |
|---|
It seems to be doing some useless actions, like joining on an array of 1 string and replacing text in multiple iterations.
I also did my best to optimize the regex without affecting functionality.
Here are some performance comparisons from JSBench.Me:

And the new real-world performance results:

Finally, I've used a better string comparison for very large array of strings. namely Intl.Collator instead of localeCompare.
See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare#performance
(I haven't yet recorded performance comparison)
Mind a review?

