Odd even sort algorithm.
Complexity: O(N^2).
Complexity: O(N^2).
- Source:
Parameters:
Name | Type | Description |
---|---|---|
array |
Array
|
Input array. |
Returns:
- Type:
-
Array
Sorted array.
Example
var sort = require('path-to-algorithms/src/' +
'sorting/oddeven-sort').oddEvenSort;
console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ]