SOURCE

console 命令行工具 X clear

                    
>
console
/**
 * 根据 html 结构实现表格排序:
    1. 点击表头 Age 根据年龄(数字)对表格行升序排序
    2. 点击表头 Name 根据姓名(字符串)对表格行降序排序
 */

grid.onclick = function (e) {
  sortGrid();
};

function sortGrid() {}
<table id="grid">
	<thead>
		<tr>
			<th data-type="number">Age</th>
			<th data-type="string">Name</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>5</td>
			<td>John</td>
		</tr>
		<tr>
			<td>2</td>
			<td>Pete</td>
		</tr>
		<tr>
			<td>12</td>
			<td>Ann</td>
		</tr>
		<tr>
			<td>9</td>
			<td>Eugene</td>
		</tr>
		<tr>
			<td>1</td>
			<td>Ilya</td>
		</tr>
	</tbody>
</table>
 table {
     border-collapse: collapse;
 }
 
 th,
 td {
     border: 1px solid black;
     padding: 4px;
 }
 
 th {
     cursor: pointer;
 }
 
 th:hover {
     background: yellow;
 }