Sorting algorithms/Bubble sort: Difference between revisions

m
→‎{{header|J}}: fix lang tags
m (J code brought closer to the specification)
m (→‎{{header|J}}: fix lang tags)
Line 569:
 
=={{header|J}}==
<lang Jj>
bubbleSort=: |. @: ((([ (>. , <.) {.@]) , }.@])/^:_)
</lang>
Line 575:
Test program:
 
<lang Jj> ?. 10 $ 10
?. 10 $ 10
4 6 8 6 5 8 6 6 6 9
bubbleSort ?. 10 $ 10
Line 582 ⟶ 581:
</lang>
 
For the most part, bubble sort works against J's strengths. However, once a single pass has been implemented as a list operation, <code>^:_</code> tells J to repeat this until the result stops changing.
 
=={{header|Java}}==
892

edits