JortSort: Difference between revisions

1,115 bytes added ,  28 days ago
Added Easylang
(→‎{{header|Vlang}}: Rename "Vlang" in "V (Vlang)")
(Added Easylang)
 
(2 intermediate revisions by 2 users not shown)
Line 650:
</syntaxhighlight>
 
 
=={{header|EasyLang}}==
<syntaxhighlight>
proc sort . d[] .
for i = 1 to len d[] - 1
for j = i + 1 to len d[]
if d[j] < d[i]
swap d[j] d[i]
.
.
.
.
func jortsort arr[] .
orig[] = arr[]
sort arr[]
return if orig[] = arr[]
.
print jortsort [ 2 4 6 ]
print jortsort [ 4 2 6 ]
</syntaxhighlight>
{{out}}
<pre>
1
0
</pre>
 
=={{header|Elixir}}==
Line 1,585 ⟶ 1,610:
=={{header|Wren}}==
{{libheader|Wren-sort}}
<syntaxhighlight lang="ecmascriptwren">import "./sort" for Sort
 
var jortSort = Fn.new { |a|
Line 1,598 ⟶ 1,623:
for (test in tests) System.print("%(test) -> %(jortSort.call(test) ? "sorted" : "not sorted")")</syntaxhighlight>
 
{{out}}
<pre>
[1, 2, 3, 4, 5] -> sorted
[2, 1, 3, 4, 5] -> not sorted
</pre>
 
=={{header|XPL0}}==
{{trans|Wren}}
<syntaxhighlight lang "XPL0">include xpllib; \for Sort
 
func JortSort(A, N);
int A, N, B, I;
def SizeOfInt = 4;
[B:= Reserve(N*SizeOfInt);
for I:= 0 to N-1 do B(I):= A(I);
Sort(B, N);
for I:= 0 to N-1 do
if B(I) # A(I) then return false;
return true;
];
 
int Tests, Test, I;
def Size = 5;
[Tests:= [ [1, 2, 3, 4, 5], [2, 1, 3, 4, 5] ];
for Test:= 0 to 2-1 do
[ChOut(0, ^[);
for I:= 0 to Size-2 do
[IntOut(0, Tests(Test,I)); Text(0, ", ")];
IntOut(0, Tests(Test,I));
Text(0, "] -> ");
Text(0, if JortSort(Tests(Test), Size) then "sorted" else "not sorted");
CrLf(0);
];
]</syntaxhighlight>
{{out}}
<pre>
1,983

edits