I need to sort a big list of Javascript items and I'm using the sort function like this:
var sorted_list = non_sorted.sort(function(a,b){
// Sort stuff here
});
What I'd like to do is to call a function when the sort function is done.
Is it possible to add a callback function to sort or to trigger an event when when sort is over?
You are overcomplicating it. The sort method isn't asynchronous, so you don't need a callback or an event. Just put your code after the code that calls sort:
var sorted_list = non_sorted.sort(function(a,b){
  // comparer
});
// The code just continues here after the sort
                        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