Sorting algorithms/Bubble sort: Difference between revisions

Content added Content deleted
(Add AWK generic sort() function for grab-and-use)
(→‎{{header|AWK}}: Fix markup)
Line 218: Line 218:
}</lang>
}</lang>


# GNU awk contains built in sort() functions, but for POSIX awk,
GNU awk contains built in sort() functions, but for POSIX awk,
# here is a simple bubblesort (adapted from above). Note, it
here is a simple bubblesort (adapted from above). Note, it
# is not possible to return arrays from function, so the
is not possible to return arrays from function, so the
# array is "edited in place". The extra parameters passed in
array is "edited in place". The extra parameters passed in
# function argument lists is well known trick to use local
function argument lists is well known trick to use local
variables.
# variables. Code by Jari Aalto <jari.aalto A T cante net>

<lang awk>
# Code by Jari Aalto <jari.aalto A T cante net>
# Licensed and released under GPL-2+ http://spdx.org/licenses/
# Licensed and released under GPL-2+ http://spdx.org/licenses/


Line 263: Line 266:
exit
exit
}
}
</lang>


=={{header|BASIC}}==
=={{header|BASIC}}==