Does Array.sort block the main thread in node.js from start to finish? If yes, is there a library that does an incremental sort (i.e. an array sort that will sort in chunks, possibly utilizing Process.nextTick ?)
Thanks!
sort() is an array function from Node. js that is used to sort a given array. Parameter: This function does not takes any parameter. Return type: The function returns the sorted array.
The sort() sorts the elements of an array. The sort() overwrites the original array. The sort() sorts the elements as strings in alphabetical and ascending order.
Example: Sort an Array in Java in Ascending Order Then, you should use the Arrays. sort() method to sort it. That's how you can sort an array in Java in ascending order using the Arrays. sort() method.
the short answer as you guys figured is nope.
More of a conceptual answer, async is meant to solve waiting for resource issues, and not heavy calculations at all
With that said, nothing stops you from having sort running in another process, and communicating with it asynchronously
I'd just be careful specially with 2 things: don't start a new process for each sort is probably a good idea if startup take some time. If you have a big array be careful with memory copy what you are sorting, if you have to anyway, you may just return the ordered indexes in the array ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With