diff --git a/app/[locale]/(main)/ClientComponents/ServerListClient.tsx b/app/[locale]/(main)/ClientComponents/ServerListClient.tsx index c111d03..f064a1a 100644 --- a/app/[locale]/(main)/ClientComponents/ServerListClient.tsx +++ b/app/[locale]/(main)/ClientComponents/ServerListClient.tsx @@ -19,14 +19,25 @@ export default function ServerListClient() { ); if (!data) return null; - const sortedServers = data.result.sort((a, b) => { - if (a.display_index && b.display_index) { - return b.display_index - a.display_index; - } - if (a.display_index) return -1; - if (b.display_index) return 1; - return a.id - b.id; - }); + const { result } = data; + + const positiveDisplayIndex = result + .filter((server) => server.display_index > 0) + .sort((a, b) => b.display_index - a.display_index); + + const noDisplayIndex = result + .filter((server) => !server.display_index) + .sort((a, b) => a.id - b.id); + + const negativeDisplayIndex = result + .filter((server) => server.display_index < 0) + .sort((a, b) => b.display_index - a.display_index); + + const sortedServers = [ + ...positiveDisplayIndex, + ...noDisplayIndex, + ...negativeDisplayIndex, + ]; return (
{sortedServers.map((serverInfo) => (