AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Sorting Arrays (https://forums.alliedmods.net/showthread.php?t=233923)

devWaleed 01-22-2014 06:48

Sorting Arrays
 
Hey, can you please help me on array sorting?

I read this: https://forums.alliedmods.net/showthread.php?t=187237

Its for SourceMod I know but languages are same.

Code:

        new nums[] = {5, 4, 3, 2, 1};
       
        SortIntegers(nums, charsmax(nums), Sort_Ascending);
       
        for(new i = 0; i <= charsmax(nums); i++){
                client_print(id, print_chat, "%i ", nums[i]);       
        }

It should print 1 first then 2, 3, 4 and 5 but its not.

jimaway 01-22-2014 07:17

Re: Sorting Arrays
 
new nums[] = {5, 4, 3, 2, 1};

SortIntegers(nums, sizeof(nums), Sort_Ascending);

for(new i = 0; i < sizeof(nums); i++){
client_print(id, print_chat, "%i ", nums[i]);
}


All times are GMT -4. The time now is 10:12.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.