chore: use same logic for all tables

This commit is contained in:
JustSong 2023-11-10 21:19:11 +08:00
parent 681fcab76f
commit 2ec50f23ab

View File

@ -286,15 +286,15 @@ const ChannelsTable = () => {
if (channels.length === 0) return;
setLoading(true);
let sortedChannels = [...channels];
if (typeof sortedChannels[0][key] === 'string') {
sortedChannels.sort((a, b) => {
return ('' + a[key]).localeCompare(b[key]);
});
} else {
sortedChannels.sort((a, b) => {
if (!isNaN(a[key])) {
// If the value is numeric, subtract to sort
return a[key] - b[key];
});
} else {
// If the value is not numeric, sort as strings
return ('' + a[key]).localeCompare(b[key]);
}
});
if (sortedChannels[0].id === channels[0].id) {
sortedChannels.reverse();
}