Order two numerical lists: Difference between revisions
Content deleted Content added
No edit summary |
|||
Line 59:
=={{header|Aime}}==
<lang aime>
ordl(list a, list b)
{
integer i, l, o;
l = min(~a, ~b);
i = 0;
while (i < l) {
if (a[i] != b[i]) {
o = a[i] < b[i];
break;
}
i += 1;
}
return i < l ? o : ~a <= ~b;
}
integer
main(void)
{
o_(ordl(list(1, 2), list(1, 2)), "\n");
o_(ordl(list(1e2, 2), list(1e2, 2, 3)), "\n");
o_(ordl(list(1, 2, 3), list(1, 2)), "\n");
o_(ordl(list(.5, 4), list(.5, 2)), "\n");
o_(ordl(list(1, 4, 2, 3), list(1, 4, 2.1, 3)), "\n");
return 0;
}</lang>
=={{header|AppleScript}}==
|