Sorting algorithms/Bubble sort: Difference between revisions
Content added Content deleted
(→{{header|Qi}}: Simplified. Qi already has a fix function built in.) |
No edit summary |
||
Line 1,716: | Line 1,716: | ||
} |
} |
||
}</lang> |
}</lang> |
||
=={{header|NetRexx}}== |
|||
<lang NetRexx>/* NetRexx */ |
|||
options replace format comments java crossref savelog symbols binary |
|||
placesList = [String - |
|||
"UK London", "US New York" - |
|||
, "US Boston", "US Washington" - |
|||
, "UK Washington", "US Birmingham" - |
|||
, "UK Birmingham", "UK Boston" - |
|||
] |
|||
sortedList = bubbleSort(String[] Arrays.copyOf(placesList, placesList.length)) |
|||
lists = [placesList, sortedList] |
|||
loop ln = 0 to lists.length - 1 |
|||
cl = lists[ln] |
|||
loop ct = 0 to cl.length - 1 |
|||
say cl[ct] |
|||
end ct |
|||
say |
|||
end ln |
|||
return |
|||
method bubbleSort(list = String[]) public constant binary returns String[] |
|||
listLen = list.length |
|||
loop i_ = 0 to listLen - 1 |
|||
loop j_ = i_ + 1 to listLen - 1 |
|||
if list[i_].compareTo(list[j_]) > 0 then do |
|||
tmpstor = list[j_] |
|||
list[j_] = list[i_] |
|||
list[i_] = tmpstor |
|||
end |
|||
end j_ |
|||
end i_ |
|||
return list |
|||
</lang> |
|||
;Output |
|||
<pre> |
|||
UK London |
|||
US New York |
|||
US Boston |
|||
US Washington |
|||
UK Washington |
|||
US Birmingham |
|||
UK Birmingham |
|||
UK Boston |
|||
</pre> |
|||
=={{header|Objeck}}== |
=={{header|Objeck}}== |