Skip to main content

Ens.Util.Sort

class Ens.Util.Sort extends %Library.RegisteredObject

Method Inventory

Methods

classmethod Quicksort(ByRef arr, ByRef output, type As %String = "c", order As %Boolean = 1, classname="", method="")
Use quicksort to sort an objectscript array or %List.

ByRef arr - the array/%List to sort. Note that %Lists take slightly longer to sort.
ByRef output - the array/%List to output the sorted results to. Will be overwritten. Must not be the same as arr, and will have strictly numerical indices.
type - which type of sort, if using a prewritten comparison. Possible values are "c" for collation, "a" for case insensitive collation, or "n" for using the numerical interpretation of an element to sort.
order - whether to sort in ascending or descending order. 1 corresponds to ascending, 0 to descending.

The next two arguments are optional arguments that can be used to supply a custom compare function so that anything can be sorted.

classname - the name of the class that has the custom compare function.
method - the name of the custom compare function. Must be a ClassMethod.
classmethod alphabeticalcompare(a, b)
Corresponds to type="a", compares two case insensitive values by their collation order
classmethod collationcompare(a, b)
Corresponds to type="c", compares two values by their collation order
classmethod numericalcompare(a, b)
Corresponds to type="n", compares two values by their numerical interpretation

Inherited Members

Inherited Methods

FeedbackOpens in a new tab