So let’s get started,
First We have to include W3.JS Library in our
So Once it is done, you have successfully included the W3.JS library and now we can use it in our html page.
So now we have to use one function of w3.js w3.sortHTML() under onclick event in any HTML tag (button, h1-h6, th ,td etc…).
This Function Needs 1st Parameter to be the id of the parent element of anything you want to Sort and 2nd Parameter to be the id of the child element you want to Sort.
You can see the below example to see how to sort List using W3.JS with a click of a button.
and you can see the example on how you can Sort table using W3.JS below.
As you can see In the above example we are using 3 parameters and the third parameter is the nth-child element to sort both Country and Capitals in this example.