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
bubbleSort=: |. @: ((([ (>. , <.) {.@]) , }.@])/^:_)
</lang>
Line 575:
Test program:
<lang
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}}==
|