| Array sort [message #915214] |
Sun, 16 September 2012 16:52  |
Dan Darnell Messages: 145 Registered: November 2011 Location: Arkansas |
Senior Member |
|
|
I am trying to figure out how array sorting is implemented in EDT. I found the sort() function in the List implementation but it takes a user-defined sort function as a parameter. I am familiar with this from the RUILib.sort() implementation in EGL CE but that function would accept null as a parameter to use a default alpha sort. Is the intention in EDT that a developer MUST provide his/her own sort function implementation or are there default implementation(s) tucked away somewhere?
I know in JavaScript that the sort() function accepts a user-defined sort function as a parameter or you can omit the function definition and get an alpha sort. That concept would be nice to have in EDT. (As I say, this is the way it was implemented in RUILib in EGL CE.)
FYI, I'm using the following as sort function implementations of my own devising...is there a better way?
function sortFunctionAlpha (a any in, b any in) returns(int)
aString string = a as string;
bString string = b as string;
if (aString < bString)
return -1;
end
if (aString > bString)
return 1;
end
return 0;
end
function sortFunctionInteger (a any in, b any in) returns(int)
return (a as int - b as int);
end
Thanks,
Dan
|
|
|