SA-MP Forums Archive
[Include] Sort multi-dimensional arrays (enums supported) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] Sort multi-dimensional arrays (enums supported) (/showthread.php?tid=343172)

Pages: 1 2 3 4 5


Re: Sort multi-dimensional arrays (enums supported) - Luis- - 28.04.2014

I may have, i'll have a look, if not i'll have to wait for Slice.


Re: Sort multi-dimensional arrays (enums supported) - Slice - 29.04.2014

I noticed that if there's a folder called "md-sort" in the same place as "md-sort.inc" the compiler crashes. Could it be that?


Re: Sort multi-dimensional arrays (enums supported) - Luis- - 30.04.2014

I have no folders called md-sort where the include is.


Re: Sort multi-dimensional arrays (enums supported) - Slice - 30.04.2014

What other includes do you have?

Come on, give me something more to go on here..


Re: Sort multi-dimensional arrays (enums supported) - iFarbod - 28.07.2014

How Can i use this for this:

Biggest gang
2nd biggest gang
3rd biggest gang


Based on Gang's turfs.


Re: Sort multi-dimensional arrays (enums supported) - iFarbod - 28.07.2014

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
Depends how your "gangs" are stored in memory and how they are ranked. Typically, you can store them in a basic 2 dimensional array with the first cell being some reference to that gang (name, ID, etc) and the second cell being whatever you use to rank them (surface area of turf, points or whatever you use) then sort that array by the second column ascending or descending depending on your needs.
Southclaw, Thanks for the help. +1

I have 51 GangZones, and i want reward players each minute of thier gameplay of score.

3 scores for players in Biggest Gang.
2 scores for players in 2nd Biggest Gang.
1 score for players in 3rd biggest gang.


Re: Sort multi-dimensional arrays (enums supported) - Banditukas - 18.08.2014

What mean index?

And i get error when i use longer

new ASDASDASD[ MAX_PLAYERS ][ 10 ][ MAX_PLAYER_NAME ];


Re: Sort multi-dimensional arrays (enums supported) - codectile - 18.08.2014

@Banditukas: Index means position of an element in an array.

Example:

new array[10]={1,2,3,4,5,6,7,8,9,10}

where,

1's index is 0
2's index is 1
3's index is 2
4's index is 3
5's index is 4
6's index is 5
7's index is 6
8's index is 7
9's index is 8
10's index is 9


Re: Sort multi-dimensional arrays (enums supported) - Banditukas - 18.08.2014

And why i need to write a specif index?


Re: Sort multi-dimensional arrays (enums supported) - Banditukas - 18.08.2014

Код:
SortDeepArray(array, 0);
Why i need to write 0 if i just want to get from my array DESC ABC ?

And problem is if you use 3d dimmension array

[ ] [] [ ]


Re: Sort multi-dimensional arrays (enums supported) - Banditukas - 18.08.2014

Can you make for 3d, or is here for 3d?


Re: Sort multi-dimensional arrays (enums supported) - BlackBank - 02.12.2014

Quote:
Originally Posted by Luis-
Посмотреть сообщение
For some reason, this include crashes my compiler, any reason why?
Same here atm... I changed something and then suddenly boem, but the problem is, i don't know what i've actualy changed anymore...


Re: Sort multi-dimensional arrays (enums supported) - vannesenn - 04.12.2014

Hi,
can somebody explain how to sort enum's variables to hightest-lowtest ?


Re: Sort multi-dimensional arrays (enums supported) - vannesenn - 04.12.2014

I saw expalins but I still don't understand how sort 2d array...
I got

Код:
new Float:_HRP_spawnStats[24]										[MAX_PLAYERS];
so I need sort arrays by values in 1st dimension(24). MAX_PLAYERS doesn't metter for now.
And where will save my sorted arrays?


Re: Sort multi-dimensional arrays (enums supported) - vannesenn - 05.12.2014

Ok, then how I can sort it?

@EDIT:

Код:
SortDeepArray(array, 0);
?

And I have problem with crashing compiler too... I tried with Zeex's compiler and nothing


Re: Sort multi-dimensional arrays (enums supported) - vannesenn - 07.12.2014

I fixed it, thanks


Re: Sort multi-dimensional arrays (enums supported) - StasWilson - 31.01.2015

Hello, how to make a top 5 for races?


Re: Sort multi-dimensional arrays (enums supported) - hab4ever - 28.08.2015

Hey is there a way to sort from a range of values eg: an array with [55][3][2][5][4][2][1][7][8][9][23] i would like to sort from a value that is in range of 0 to 10 , it would become : [1][2][2][3][4][5][7][8][9][55][23].


Re: Sort multi-dimensional arrays (enums supported) - Slice - 28.08.2015

Yeah you just need a simple quicksort for that.

I made a pretty good implementation that doesn't use recursion, which makes it safe from stack overflows.

http://forum.sa-mp.com/showpost.php?...postcount=3437


Re: Sort multi-dimensional arrays (enums supported) - hab4ever - 28.08.2015

Quote:
Originally Posted by Slice
Посмотреть сообщение
Yeah you just need a simple quicksort for that.

I made a pretty good implementation that doesn't use recursion, which makes it safe from stack overflows.

http://forum.sa-mp.com/showpost.php?...postcount=3437
thanks for replying , is it possible to sort a two dimensional array, eg: for a top finish time array that has
[time][playerid] the time is in milliseconds so if someone (hacker) finishes with time 1 second (1000ms) it wont sort it but if someone finishes with 1001ms it will sort it.