-
Notifications
You must be signed in to change notification settings - Fork 1
array_insertion_sort
Hyomoto edited this page Jun 13, 2021
·
2 revisions
Jump To | Go Back |
Arguments |
---|
Returns: [N/A undefined
](N/A undefined
)
Throws: InvalidArgumentType
A sort-in-place, stable algorithm for arrays. While less efficient than quick or merge sort, can be very efficient on small arrays due to its simple code. If sort_or_func is true, or not provided, the array will be sorted by ascending value. Setting this to false will use descending logic. If a method is provided, this will be used for the comparison. If an array is not provided to sort, or a non-boolean, non-method is provided for sort, InvalidArgumentType will be thrown.
var _array = [ 10, 4, 15, 23, 12, 4 ];
array_insertion_sort( _array );
Output: [ 4,4,10,12,15,23 ]
Name | Type | Purpose |
---|---|---|
array | array |
An array to sort |
*sort_or_func | mixed |
optional: The sort logic to use |
Devon Mullane 2020