Module Array
A module with helper functions related to array style tables.
Info:
- License: MIT
- Author: Richard Voelker
Functions
InsertionSort (array, comparisonFn) | Perform an insertion sort on the array. |
Merge (left, right, comparisonFn) | The merge operation of the merge sort; merges two halves of an array into one. |
ComparisonOrder () | An enum type that allows for default sorting functions in the StableSort if the user doesn't one to define their own. |
StableSort (array[, comparisonFn=ComparisonOrder.Ascending]) | Sort an array, making sure the order of elements with the same sorting value appear in the same order they were in before. |
Reverse (array) | Reverses the order of the elements in an array. |
Functions
- InsertionSort (array, comparisonFn)
-
Perform an insertion sort on the array.
Parameters:
- array array The array to be sorted.
- comparisonFn function The function to compare any two elements in the array. Parameters are the left and right side.
Returns:
-
array
The sorted array.
- Merge (left, right, comparisonFn)
-
The merge operation of the merge sort; merges two halves of
an array into one.
Parameters:
- left array The left half of the array.
- right array The right half of the array.
- comparisonFn function The function to compare any two elements in the array. Parameters are the left and right side.
Returns:
-
array
The merged array.
- ComparisonOrder ()
- An enum type that allows for default sorting functions in the StableSort if the user doesn't one to define their own.
- StableSort (array[, comparisonFn=ComparisonOrder.Ascending])
-
Sort an array, making sure the order of elements with the
same sorting value appear in the same order they were in
before.
Parameters:
- array array The array to sort
- comparisonFn function/ComparisonOrder The function to compare any two elements in the array. Parameters are the left and right side. May also use ComparisonOrder to use on of the default comparison functions. (default ComparisonOrder.Ascending)
Returns:
-
array
The sorted array.
- Reverse (array)
-
Reverses the order of the elements in an array.
Parameters:
- array array The array to reverse.