Added event listener for sorting function.