Update sorting method for id (token)

This commit is contained in:
Baksi 2023-11-10 04:16:34 +08:00 committed by GitHub
parent 1ffed0d1c7
commit 03f96160cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -228,7 +228,13 @@ const TokensTable = () => {
setLoading(true); setLoading(true);
let sortedTokens = [...tokens]; let sortedTokens = [...tokens];
sortedTokens.sort((a, b) => { sortedTokens.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]); return ('' + a[key]).localeCompare(b[key]);
}
}); });
if (sortedTokens[0].id === tokens[0].id) { if (sortedTokens[0].id === tokens[0].id) {
sortedTokens.reverse(); sortedTokens.reverse();