Raised This Month: $ Target: $400
 0% 

Sorting an array..?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Deviance
Veteran Member
Join Date: Nov 2004
Location: Sweden
Old 12-28-2006 , 15:33   Sorting an array..?
Reply With Quote #1

Example
Code:
new randomarray[5] randomarray[0] = 42 randomarray[1] = 27 randomarray[2] = 81 randomarray[3] = 22 randomarray[4] = 68
How would i sort this array so the biggest number is first and the lowest number is last?
Deviance is offline
P34nut
AMX Mod X Beta Tester
Join Date: Feb 2006
Location: Netherlands
Old 12-28-2006 , 15:35   Re: Sorting an array..?
Reply With Quote #2

http://www.amxmodx.org/funcwiki.php?...sort&go=search
__________________
All you need to change the world is one good lie and a river of blood
P34nut is offline
Deviance
Veteran Member
Join Date: Nov 2004
Location: Sweden
Old 12-28-2006 , 15:36   Re: Sorting an array..?
Reply With Quote #3

Quote:
Originally Posted by P34nut View Post
hmm, looks like that's it, thx!
Deviance is offline
Deviance
Veteran Member
Join Date: Nov 2004
Location: Sweden
Old 12-29-2006 , 20:33   Re: Sorting an array..?
Reply With Quote #4

Damn, new problem!

For example..
Code:
new randomarray[4] randomarray[2] = 44 randomarray[1] = 2 randomarray[4] = 85 randomarray[3] = 99
How would i do so the array's number is still the same after i've sorted it?

Like...
Code:
new randomarray[4] randomarray[3] = 99 randomarray[4] = 85 randomarray[2] = 44 randomarray[1] = 2
Instead of...
Code:
new randomarray[4] randomarray[2] = 99 randomarray[1] = 85 randomarray[4] = 44 randomarray[3] = 2
Deviance is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 12-29-2006 , 20:37   Re: Sorting an array..?
Reply With Quote #5

Copy the array before you sort it? Or at least that is what I did in my C# project.
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 12-29-2006 , 20:47   Re: Sorting an array..?
Reply With Quote #6

You can't sort an array and leave all of the indexes the same.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Deviance
Veteran Member
Join Date: Nov 2004
Location: Sweden
Old 12-29-2006 , 20:48   Re: Sorting an array..?
Reply With Quote #7

Quote:
Originally Posted by XxAvalanchexX View Post
You can't sort an array and leave all of the indexes the same.
How does the rank system work then?
I've trying to do something like that, just that my method isn't working

Last edited by Deviance; 12-29-2006 at 21:02.
Deviance is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 12-29-2006 , 21:32   Re: Sorting an array..?
Reply With Quote #8

Doom why not copy the array?
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
Deviance
Veteran Member
Join Date: Nov 2004
Location: Sweden
Old 12-29-2006 , 21:48   Re: Sorting an array..?
Reply With Quote #9

Quote:
Originally Posted by SweatyBanana View Post
Doom why not copy the array?
I've dunno how i would copy it, and i have already tried it. Could you explain how you mean?
Deviance is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 12-29-2006 , 21:53   Re: Sorting an array..?
Reply With Quote #10

Code:
new randomarray[4]; randomarray[2] = 44 randomarray[1] = 2 randomarray[4] = 85 randomarray[3] = 99 new sortedarray[4]; sortedarray = randomarray; // sort sortedarray
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX 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 22:28.


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