Array.sort and Node.js

Does Array.sort share the main thread in node.js from start to finish? If so, is there a library that does incremental sorting (i.e. sorting an array that will sort in pieces, perhaps using Process.nextTick?)

Thanks!

+7
source share
2 answers

the short answer is how you guys haven't.

A more conceptual answer, async is for solving pending resource issues, not for heavy computing in general

With that said, nothing prevents you from having sorting in another process and communicating with it asynchronously

I would be very careful about two things: do not start a new process for each type, probably a good idea if it takes a while to start. If you have a large array, be careful with the copy of the memory you are sorting, if you don't care, you can simply return the ordered indices in the array;)

+2
source

Sort in a separate thread

Not to be confused with multithreaded sorting, this HTML5 web worker demo shows you how to sort in a separate thread , thereby freeing up your main thread to do other things.

0
source

All Articles