Jump to content

Sorting algorithms/Quicksort: Difference between revisions

m
→‎{{header|Tailspin}}: Neater expression
m (→‎{{header|Fortran}}: added syntax highlighting)
m (→‎{{header|Tailspin}}: Neater expression)
Line 9,509:
def last: $(2);
def pivot: $@quicksort($first);
[@: $first(1) + 1, $last ] -> #;
$(2) -> #
 
when <?($(2) <..~$(1)>)@> do
def limit: $(2);
@quicksort($first): $@quicksort($limit);
@quicksort($limit): $pivot;
Line 9,518 ⟶ 9,519:
[ $limit + 1, $last ] !
 
when <?($@quicksort($(2)) <$pivot~..>)> do
[ $(1), $(2) - 1] -> #
 
when <?($@quicksort($(1)@) <..$pivot>)> do
[@: $(1)@ + 1,; $(2)] -> #
 
otherwise
def temp: $@quicksort($(1)@);
@quicksort($(1)@): $@quicksort($(2));
@quicksort($(2)): $temp;
[@: $(1)@ + 1,; $(2) - 1] -> #
end partial
@: $;
18

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.