Hi,
I have an array of numbers : var _tstArray = new Array(10,20,30,100,200,300,101,201,301) and i need to sort it numeric !!
If i use the Servoy sort I end up with : 10,100,101,20,200,201,30,300,301 which is a string sort.
Is there a way to do this numeric ?
Regards,
If you didn’t feel like dedicating a global, or even form based function to this you can just create a local function to deal with it.
If you’re in Servoy 4 something like this:
var fMySort = function (a, b) { return a-b; }
var _tstArray = new Array(10,20,30,100,200,300,101,201,301)
_tstArray.sort(fMySort);
If you’re still in 3 then you should try
var fMySort = new Function(“a”, “b”, “return a-b;”)
var _tstArray = new Array(10,20,30,100,200,300,101,201,301)
_tstArray.sort(fMySort);