Order two numerical lists: Difference between revisions
Content deleted Content added
Added Elixir |
Added Sidef |
||
Line 1,354: | Line 1,354: | ||
FALSE |
FALSE |
||
FALSE |
FALSE |
||
</pre> |
|||
=={{header|Sidef}}== |
|||
Built-in, via the comparison operator (`<=>`): |
|||
<lang ruby>func ordered(a, b) { |
|||
(a <=> b) < 0 |
|||
} |
|||
for p in [ |
|||
Pair([1,2,4], [1,2,4]), |
|||
Pair([1,2,4], [1,2] ), |
|||
Pair([1,2], [1,2,4]), |
|||
] { |
|||
var a = p.first |
|||
var b = p.second |
|||
var before = ordered(a, b) |
|||
say "#{a} comes before #{b} : #{before}" |
|||
}</lang> |
|||
{{out}} |
|||
<pre> |
|||
[1, 2, 4] comes before [1, 2, 4] : false |
|||
[1, 2, 4] comes before [1, 2] : false |
|||
[1, 2] comes before [1, 2, 4] : true |
|||
</pre> |
</pre> |
||