**** Algorithm class with various sorting routines. This class is a stateless collection of functions and may be used without instantiation. Sather has no way of distinguishing such modules currently _ Usage: __a_sorter:_A_SORT{FLT,ARRAY{FLT}}; __a:_ARRAY{FLT}_:=_|1.0,2.0,3.0,1.0|; __a_sorter.sort(a); __is_sorted:_BOOL_:=_A_SORT{FLT,ARRAY{FLT}}::is_sorted(a); _ __Define_your_own_comparison_function_using_a_bound_routine: _____comp(f1,f2:_FLT):_BOOL_is _______if_f1_<_f2_then_return_true_else_return_false_end; _____end; __b:_ARRAY{FLT}_:=_|1.0,3.0,2.0|; __comp_fn:_ROUT{FLT,FLT}:BOOL_:=_bind(comp(_,_)); __a_sorter.quicksort_by(b,comp_fn,0,b.size-1); _

Flattened version is here

Ancestors
 COMPARE{_}

Public

Features
 **** Return the number of unique elements. Assume that self is sorted
insertion_sort(a: ATP)
 **** Indirect insertion sort. As a result of sorting "l" to "u", "order" will be rearranged to contain the indicies of the elements of self in sorted order
 **** Stably sort the elements of self between `l' and `u' inclusive by insertion sort. `elt_lt' defines the ordering.
 **** Indirect insertion sort. As a result of sorting "l" to "u", "order" will be rearranged to contain the indicies of the elements of self in sorted order
 **** Stably sort the elements of self using `t' to define "less than". Self may be void.
 **** True if the elements of self are in sorted order according to `elt_lt'. Self may be void.
 **** Returns true if self is sorted using the indirect array "order" between indices "l" and "u"
 **** True if the elements of self are in sorted order according to `elt_lt'. Self may be void.
is_sorted_by(a: ATP,lt: ROUT{ETP,ETP}:BOOL): BOOL
 **** Returns true if self is sorted using the indirect array "order" between indices "l" and "u", by comparison criterion "lt"
 **** Returns true if self is sorted using the comparison criterion "lt"
 **** Merge a1 and a2 into the destination array "into"
merge_sort_by(into: ATP, a1,a2: ATP,lt: ROUT{ETP,ETP}:BOOL)
 **** Use quicksort to sort the elements of self from `l' to `u' inclusive according to `elt_lt'.
 **** Quick
 **** Default sorting uses quicksort and sorts the whole array
 **** Sort the whole array "a" using the comparison function "lt"
 **** Sort the range of array elements in the index range from "l" to "u"

Private

check_range(a: ATP,l,u: INT): BOOL
 **** When to stop the quicksort recursion and switch to insertion sort.
swap(a: ATP,order: ARRAY{INT},i,j: INT)
swap(a: ATP,i,j: INT)