Add pagination and sorting in JavaScript to HTML tables