Raised This Month: $ Target: $400
 0% 

Sorting Arrays


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
devWaleed
Member
Join Date: Apr 2013
Location: Karachi, Pakistan
Old 01-22-2014 , 06:48   Sorting Arrays
Reply With Quote #1

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.

Last edited by devWaleed; 01-22-2014 at 06:57.
devWaleed is offline
Send a message via Skype™ to devWaleed
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 01-22-2014 , 07:17   Re: Sorting Arrays
Reply With Quote #2

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]);
}
jimaway is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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