Gamestudio Links
Zorro Links
Newest Posts
Using ":L" & ":S" causes 2 possible bug(s) or is it bad coding?
by AndrewAMD
8 minutes 26 seconds ago
Help with Data import to T1
by OptimusPrime
Today at 19:44
How to ensamble multiple algos with advise calls?
by laz
Today at 18:53
Correlation -1.#IND00
by AndrewAMD
01/21/19 17:37
Basic thread safety question
by Superku
01/20/19 18:15
Blog Post: Get Historical Data from Darwinex REST API w/ Zorro
by AndrewAMD
01/19/19 22:19
Reseting a static variable - the next day
by OptimusPrime
01/19/19 19:48
AUM Magazine
Latest Screens
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Evonet Beta v1.0 : Online Project Development Template
Lake scene
Who's Online
12 registered (OptimusPrime, AndrewAMD, jacek, Dalla, kvm, Quad, Iglarion, ibne, misiek, 3 invisible), 489 Guests and 7 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
jthbln, laz, ramonne, SibJac, Evael
18157 Registered Users
Topic Options
Rate This Topic
#464838 - 03/14/17 18:16 sortIdx
hatten Offline
Newbie

Registered: 07/01/16
Posts: 47
When using sortIdx I run into the problem that this function apparently checks the lookback period and yields and error if the number of elements of the array you wish to sort exceeds the lookback period. However I do wish to sort an array that is not a time series and whose dimension is unrelated to lookback issues. This function should be in file functions.c as it is declared in function.h. Unfortunately function.c is not part of the distribution, otherwise it would be easy to just copy the code for sortIdx and remove checklookback command, which I assume is the problem. Anyone has a code snippet for sorting as sortIdx does? The standard qsort c++ function is different as it rearranges the elements of the original array which I don't want.

Top
#470424 - 01/13/18 16:09 Re: sortIdx [Re: hatten]
sdh309795gaas Offline
Member

Registered: 12/07/14
Posts: 104
Same question here!


This doesn't work:


function main()
{
int n;
var myarray[4] = {1.5, 2.3, 0.1, 0.001};

int Idx = sortIdx(myarray, 4);

for(n=0, n < 4, n++)
{
printf("n%dth Index = %d",n,Idx[n]);
}


}

Top
#470439 - 01/14/18 20:19 Re: sortIdx [Re: sdh309795gaas]
oligodar Offline
Newbie

Registered: 12/08/13
Posts: 14
This code works for me:

Code:
function main(){
	int n;
	var myarray[4] = {1.5, 2.3, 0.1, 0.001};
	int* Idx = sortIdx(myarray, -4);
	for(n=0; n < 4; n++){
	    printf("\n%dth Index = %d",n,Idx[n]);
	}
}




in zorro 1.744


Edited by oligodar (01/14/18 20:24)

Top
#470447 - 01/15/18 10:58 Re: sortIdx [Re: oligodar]
jcl Offline

Chief Engineer

Registered: 07/22/00
Posts: 26694
Loc: Frankfurt
AFAIK, sortIdx does not check the lookback period and the number of elements does not matter. Maybe you were using a very old Zorro version.

Top



Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de