score:1

Accepted answer

The problem is the way in which you're setting up the handler functions for the click events. You're selecting all the buttons and attaching a single handler that determines internally what to do. This handler runs code to update the bars for all buttons, regardless of what happened before.

In your particular case, this means that the sorting is done correctly and the corresponding transitions set up, but then immediately cancelled by the code that's updating the bars (to handle added/removed values). This doesn't do anything in this case, so the only effect is to cancel everything that the sort handler set up.

To fix, simply exit the function after the call to the sorting functions:

return;

Complete demo here.


Related Query

More Query from same tag