chore: use same logic for all tables
This commit is contained in:
parent
681fcab76f
commit
2ec50f23ab
@ -286,15 +286,15 @@ const ChannelsTable = () => {
|
|||||||
if (channels.length === 0) return;
|
if (channels.length === 0) return;
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
let sortedChannels = [...channels];
|
let sortedChannels = [...channels];
|
||||||
if (typeof sortedChannels[0][key] === 'string') {
|
sortedChannels.sort((a, b) => {
|
||||||
sortedChannels.sort((a, b) => {
|
if (!isNaN(a[key])) {
|
||||||
return ('' + a[key]).localeCompare(b[key]);
|
// If the value is numeric, subtract to sort
|
||||||
});
|
|
||||||
} else {
|
|
||||||
sortedChannels.sort((a, b) => {
|
|
||||||
return a[key] - b[key];
|
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) {
|
if (sortedChannels[0].id === channels[0].id) {
|
||||||
sortedChannels.reverse();
|
sortedChannels.reverse();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user