Writing a Non-blocking JavaScript Quicksort

added by bpwndaddy
6/10/2015 2:55:59 PM

1 Kicks, 183 Views

I've recently had some fun writing a browser quicksort. As part of a recent project, I had to implement a Knockout table component that could sort and filter its entries in realtime. This would normally have been straightforward, except for a handful of use-cases where the table would contain upwards of three thousand entries – possibly more. Calling a native array sort() on such a large set with a particularly complex comparator would force IE8 to freeze for several seconds and throw a long running script error. Server-side sorting was awkward for various reasons, and we weren’t terribly keen on the complications that AJAX imposed. What we really wanted was a non-blocking JavaScript sort.