Commit b90b8a9d by quzard Committed by GitHub

fix: fix channel table's sorting problem (#188)

parent 99e330d9
...@@ -238,9 +238,17 @@ const ChannelsTable = () => { ...@@ -238,9 +238,17 @@ const ChannelsTable = () => {
if (channels.length === 0) return; if (channels.length === 0) return;
setLoading(true); setLoading(true);
let sortedChannels = [...channels]; let sortedChannels = [...channels];
sortedChannels.sort((a, b) => { if (typeof sortedChannels[0][key] === 'string'){
return ('' + a[key]).localeCompare(b[key]); sortedChannels.sort((a, b) => {
}); return ('' + a[key]).localeCompare(b[key]);
});
} else {
sortedChannels.sort((a, b) => {
if (a[key] === b[key]) return 0;
if (a[key] > b[key]) return -1;
if (a[key] < b[key]) return 1;
});
}
if (sortedChannels[0].id === channels[0].id) { if (sortedChannels[0].id === channels[0].id) {
sortedChannels.reverse(); sortedChannels.reverse();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment