Sort disjoint sublist: Difference between revisions

Added XPL0 example.
m (→‎{{header|Phix}}: syntax coloured, made p2js compatible)
(Added XPL0 example.)
Line 3,033:
Initial: [7, 6, 5, 4, 3, 2, 1, 0]
Sorted : [7, 0, 5, 4, 3, 2, 1, 6]
</pre>
 
=={{header|XPL0}}==
<lang XPL0>include xpllib; \for Sort routine
int Values, Indices, J, I, T;
[Values:= [7, 6, 5, 4, 3, 2, 1, 0];
Indices:= [6, 1, 7];
Sort(Indices, 3);
for J:= 3-1 downto 0 do \bubble sort values at Indices
for I:= 0 to J-1 do
if Values(Indices(I)) > Values(Indices(I+1)) then
[T:= Values(Indices(I));
Values(Indices(I)):= Values(Indices(I+1));
Values(Indices(I+1)):= T;
];
for I:= 0 to 8-1 do
[IntOut(0, Values(I)); ChOut(0, ^ )];
]</lang>
 
{{out}}
<pre>
7 0 5 4 3 2 1 6
</pre>
 
772

edits