JSFiddle - React, Tailwind, and code Playground

by ppgab

HTML

<table id="myTable">
            <thead>
                <tr>
                    <th scope="col">Number</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>3</td>
                </tr>
                <tr>
                    <td>2</td>
                </tr>
                <tr>
                    <td>1</td>
                </tr>
            </tbody>
        </table>
        
        This table should be in order

JavaScript

t = document.getElementById('myTable');
[...t.tBodies[0].rows]
.sort( (a,b) => a.cells[0].textContent > b.cells[0].textContent)
.forEach(r => t.tBodies[0].insertAdjacentElement('beforeend',r))