2 回答

TA貢獻1936條經驗 獲得超7個贊
在您的代碼中,您只對第一列進行排序.. 可以嗎?
const Cmds = [
"/server",
"/msg",
"/r",
"/island,/is",
"/towny,/t",
"/nation,/n",
"/echest",
"/craft,/wb,/workbench",
"/tpa",
"/tpahere",
"/tpaccept"
];
const Args = [
"(servername)",
"(playname) (message)",
"(message)",
"(optional)",
"(optional)",
"(optional)",
"N/A",
"N/A",
"(playername)",
"(playername)",
"N/A"
];
const Usage = [
"Used to switch between the hub and gamemodes.",
"Used to send a pm to a player.",
"Sends a pm to the player you last sent/recieved a pm from.",
"Without args opens gui. With args open a specific section.",
"Without args displays town info. With args you can config your town.",
"Without args displays nation info. With args you can config your nation.",
"Open your enderchest via a command.",
"Open a crafting table via a command.",
"Sends a request to teleport to a player.",
"Sends a request to teleport to a player to you.",
"Accepts the last pending teleport request."
];
const Server = [
"*",
"*",
"*",
"Skyblock",
"Towny",
"Towny",
"Towny/Skyblock",
"Towny/Skyblock",
"Towny/Skyblock",
"Towny/Skyblock",
"Towny/Skyblock"
];
const Rank = [
"*",
"*",
"*",
"* (Skyblock owner)",
"* (Town owner)",
"* (Town owner)",
"Donator,Donator+,DonatorPro,*Staff",
"Donator,Donator+,DonatorPro,*Staff",
"*",
"*",
"*"
];
Cmds.sort().reverse();
var table = document.getElementById("cmdlist");
for (let i = 0; i < Cmds.length; i++) {
var row = table.insertRow(i+1);
[
Cmds,
Args,
Usage,
Server,
Rank
].forEach((column, index) => {
row.insertCell(index).innerHTML = column[i]
})
}
table, th, td {
border: 1px dotted #cdcdcd;
}
tr:nth-child(even) {
background: #eee
}
tr:nth-child(odd) {
background: #FFF
}
th {
background-color: #000;
color: white;
}
<table id="cmdlist">
<tr>
<th>Command</th>
<th><i style="color: rgb(0,255,255);">Tuple</i> Arguments</th>
<th>Usage</th>
<th>Server(s)</th>
<th>Rank</th>
</tr>
</table>
添加回答
舉報