Create an order rule, used in orderBy
, and can also be used to binary search from or binary insert into array with object type items
Rest parameters of type key
or OrderFunction
which will return a key
, or [key
/ OrderFunction
, OrderDirection
].
Binary find the index from array
the value at where equals to item
.
Returns -1
if not found.
The array to lookup.
The item to search.
Binary find an index from array
to insert item
and keep current order.
Returned value betweens 0 ~ array.length
.
The array to lookup.
The item to compare.
Binary insert an item
into array
and keeps current order.
Note it uses splice
to insert item, it's very slower since it reallocates memory frequently.
The array to lookup.
The item to insert.
Compare two items.
When order
is 1
: returns 0
if they are same; returns -1
if the first one less that the second one; else returns 1
.
When order
is -1
: returns 0
if they are same; returns 1
if the first one less that the second one; else returns -1
.
First item.
Second item.
Sort array
inside by the order specified by current object.
The array to sort.
Generated using TypeDoc
Class to do multiple columns object array ordering.